Showing source code for /jcd/useful/webcon/2005/databases.php

Show normal

More about showing source

 

<?php
include "header.php";
include 
"navbar.php";
?>

<p><?=$psuicon?><i class=link>php.scripts.psu.edu</i> 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:</p>

<ul>

<li><p><?=$psuicon?>Be advised the security of the <i
class=link>php.scripts.psu.edu</i> server is of the same level as that
of the <i class=link>test.scripts.psu.edu</i> 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.</p>

<li><p><?=$psuicon?><i class=link>php.scripts.psu.edu</i> 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 <i class=link>php.scripts.psu.edu</i>.  The
following IPs are used at this time (June 2005):</p>

<p class="border">128.118.142.34<br>128.118.142.43</p>

<p>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:</p>

<p class="border">128.118.142.34 - 128.118.142.46 inclusive<br>
or the CIDR notation: 128.118.142.32/28</p>

<li><p>Examples:</p>

  <ul>
  <li><p><a href="http://php.net/manual/en/ref.mysql.php">MySQL</a></p>
<?php $tmp = <<<END
<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>
END;
print_code($tmp);
?>


  </ul>


</ul>

<?php
include "navbar.php";
include 
"footer.php";
?>

 

Penn State

Web Conference 2005

Writing PHP for ITS/ASET Web services

Tips 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:

<- 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

Show normal

Last update on: Mon Jun 13, 2005, 1:07:56 AM