![]() |
Web Conference 2005Writing PHP for ITS/ASET Web servicesTips on Using Remote Databases |
![]() |
| <- Back - Saving Data in SQLite Database Files | | | Up | | | Saving Data on the Client - Next -> |
php.scripts.psu.edu has been prepared
for connections to remote MySQL and PostgreSQL databases. While we do
not currently provide a database service using these brands, you may
use a database service hosted by another unit of the University or by a
commercial vendor. The following tips should help you in that
endeavor:
Be advised the security of the php.scripts.psu.edu server is of the same level as that
of the test.scripts.psu.edu server. This means that
anyone with a Penn State Access Account and Web space may run an
application with the same privileges as yours. Any access you give to
a database account whose password you provide in your script will be
accessible to everyone with an account. You may wish to limit exposure
to sensitive data while using this service. We hope to have a higher
security version of the server in the future.
php.scripts.psu.edu is a
load-balanced service. Connections your scripts make to remote
database servers will originate from another set of IP addresses than
those used for the hostname php.scripts.psu.edu. The
following IPs are used at this time (June 2005):
128.118.142.34
128.118.142.43
You may need to know this if your database host restricts access by IP address. The above list may change at a future date without prior warning. To be sure you will have all of the possible IP addresses we may use registered with the database service, use the following network range:
128.118.142.34 - 128.118.142.46 inclusive
or the CIDR notation: 128.118.142.32/28
Examples:
<html>
<body>
<?php
$hostname = "database.somevendor.com";
$user = "payaccount";
$pass = "ck1nth3M@l"
$db = "payaccount_tablespace";
$query = "SELECT isbn,title,author from TABLE booklist WHERE duedate < 20050615")
$link = mysql_connect($hostname,$user,$pass);
$db_selected = mysql_select_db($db,$link);
$result = mysql_query($query,$db_selected);
$table = "<table border=1><tr><th>ISBN</th><th>Title</th><td>Author</td></tr>\n";
while($line = mysql_fetch_array($result)) {
$table .= '<tr><td>' . $line['isbn'] . '</td><td>' . $line['title'] . '</td><td>' . $line['author'] . "</td></tr>\n";
}
$table .= "</table>\n";
echo $table;
?>
</body>
</html>
| <- Back - Saving Data in SQLite Database Files | | | Up | | | Saving Data on the Client - Next -> |
|
If you have any questions, feel free to ask me. Content by: Jeff D'Angelo <jcd@psu.edu> © 2005 Last update on: Mon Jun 13, 2005, 1:07:56 AM |
|