PHP and Oracle
| From: | GEORGINA ELAINE BAILEY | Date: | Sun, 07 Oct 2001 09:01:10 +0000 |
| Subject: | PHP and Oracle | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-13079@lists.php.net to get a copy of this message | ||
I am very new to PHP and databases and have not really had very much
programming practice. However, I am trying to create a Web page that
retrieves data from an Oracle database and uses php to display the content
in a HTML format. For some reason though my script just doesn't seem to
work, despite the fact that I know there is data in the database that
matches the criteria and I know that the query works when used directly in
Oracle. The only prints the final three HTML links at the bottom of the
script. I thought at first that it was something to do with the database
not being able to understand multiple values in the keyword field, so that
is why keyword is currently a radio button.
Any ideas? But please make them easy enough for a 3 year old to
understand.Please don't tell me to change the file type to just php rather
than php4 though, cos i have tried that and it just stopped the whole Web
site working.
Georgina Bailey
<html> <head> <title>Project Database - Project Search</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <h1 align="center">Project Search</h1> <form action="http://users.aber.ac.uk/geb97/search1.php4" method="POST"> <h2 align="center">Please select the relevant module and then check the area(s) that may interest you</h2> <h4 align="center"> If, for example, you would like to see all projects that involve Java, check the Java box. If you would like only those that involve both Java and databases, check both boxes. You must check at least one box</h4> <p> <input type="radio" name="moduleID" value="CS39030" checked="checked"><big>CS39030</big><br/> <input type="radio" name="moduleID" value="CS39110"><big>CS39110</big><br/> <input type="radio" name="moduleID" value="CS49060"><big>CS49060</big><br/> <input type="radio" name="moduleID" value="CSM9060"><big>CSM9060</big><br/> <input type="radio" name="moduleID" value="CSM9260"><big>CSM9260</big><br/> </p> <p> <input type="radio" name="keyword" value="java" checked="checked"><big>Java</big><br/> <input type="radio" name="keyword" value="telematics"><big>Telematics</big><br/> <input type="radio" name="keyword" value="artificialIntelligence"><big>Artificial Intelligence</big><br/> <input type="radio" name="keyword" value="databases"><big>Databases</big><br/> <input type="radio" name="keyword" value="68HC11"><big>68HC11 Assembly Language</big><br/> <input type="radio" name="keyword" value="web"><big>Web Development</big><br/> <input type="radio" name="keyword" value="others"><big>Other Programming Languages</big><br/> </p> <p> <div align="center"><input type="submit" value="Submit"/> <input type="reset" value="Reset"/></div> </p> </form> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </pre></div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu.html">Return to Project Database Main Menu</a> </pre></div> </body> </html> <html> <head> <title>Project Database - Search Results</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <?php if ($submit == "Submit") { // The submit button was clicked! // Get the input and use it to retrieve information from the database. //make a connection to the database PutEnv("ORACLE_HOME=/usr/local/applic/oracle/816"); $connection = OCILogon("geb97","f8s0g99","trdb"); //if a connection to the database is not made output a message if (!$connection) { echo "I couldn't make a connection!"; exit; } //formulate the query $query = "SELECT PROJECT.originator, PROJECT.title, PROJECT.projectID, PROJECT.status, PROJECT.specialSkills, PROJECT.moduleID from PROJECT, PROJKEY, KEYWORD, MODULE WHERE PROJECT.projectID=PROJKEY.projectID AND KEYWORD.keyID=PROJKEY.keyID AND PROJECT.moduleID='$moduleID' AND KEYWORD.keyword='$keyword'"; //parse the statement $qry_statement = OCIParse ($connection, $query); //or die ("Couldn't parse statement"); //execute the query statement OCIExecute($qry_statement); //or die ("Couldn't execute query"); //echo "<table align=\"center\" border=\"1\" cellpadding=\"8\" cellspacing=\"2\" bgcolor=\"silver\">"; //echo " <tr valign=\"center\"><th>ORIGINATOR</th><th>TITLE</th><th>PROJECT NUMBER</th><th>AVAILABILITY</th><th>SPECIAL //SKILLS</th></tr> //retrieve the results of the query statement and present them in the following way while (ocifetch($qry_statement)) { echo "The Originator is:" .OCIresult($qry_statement, 'ORIGINATOR'); echo "The title is:" .OCIresult($qry_statement, 'TITLE'); echo "The projectID is: ". OCIresult($qry_statement, 'PROJECTID'); echo "The availabilty is: ". OCIresult($qry_statement, 'AVAILABILITY'); echo "The special skills are: ". OCIresult($qry_statement, 'SPECIALSKILLS'); //echo "<tr align =\"center\"><td>" .OCIresult($qry_statement, 'ORIGINATOR'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'TITLE'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'PROJECTID'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'AVAILABILITY'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'SPECIALSKILLS'). "</td></tr>"; } //log off the database OCILogoff ($connection); } ?> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu.html">Return to Project Database Main Menu</a> </pre></div> </body> </html>
<html> <head> <title>Project Database - Project Search</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <h1 align="center">Project Search</h1> <form action="http://users.aber.ac.uk/geb97/search1.php4" method="POST"> <h2 align="center">Please select the relevant module and then check the area(s) that may interest you</h2> <h4 align="center"> If, for example, you would like to see all projects that involve Java, check the Java box. If you would like only those that involve both Java and databases, check both boxes. You must check at least one box</h4> <p> <input type="radio" name="moduleID" value="CS39030" checked="checked"><big>CS39030</big><br/> <input type="radio" name="moduleID" value="CS39110"><big>CS39110</big><br/> <input type="radio" name="moduleID" value="CS49060"><big>CS49060</big><br/> <input type="radio" name="moduleID" value="CSM9060"><big>CSM9060</big><br/> <input type="radio" name="moduleID" value="CSM9260"><big>CSM9260</big><br/> </p> <p> <input type="radio" name="keyword" value="java" checked="checked"><big>Java</big><br/> <input type="radio" name="keyword" value="telematics"><big>Telematics</big><br/> <input type="radio" name="keyword" value="artificialIntelligence"><big>Artificial Intelligence</big><br/> <input type="radio" name="keyword" value="databases"><big>Databases</big><br/> <input type="radio" name="keyword" value="68HC11"><big>68HC11 Assembly Language</big><br/> <input type="radio" name="keyword" value="web"><big>Web Development</big><br/> <input type="radio" name="keyword" value="others"><big>Other Programming Languages</big><br/> </p> <p> <div align="center"><input type="submit" value="Submit"/> <input type="reset" value="Reset"/></div> </p> </form> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </pre></div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu.html">Return to Project Database Main Menu</a> </pre></div> </body> </html> <html> <head> <title>Project Database - Search Results</title> </head> <body bgcolor="#9966FF" link="lime" vlink="yellow"> <div align="center"><img src="compSciPageBanner.gif"/></div> <?php if ($submit == "Submit") { // The submit button was clicked! // Get the input and use it to retrieve information from the database. //make a connection to the database PutEnv("ORACLE_HOME=/usr/local/applic/oracle/816"); $connection = OCILogon("geb97","f8s0g99","trdb"); //if a connection to the database is not made output a message if (!$connection) { echo "I couldn't make a connection!"; exit; } //formulate the query $query = "SELECT PROJECT.originator, PROJECT.title, PROJECT.projectID, PROJECT.status, PROJECT.specialSkills, PROJECT.moduleID from PROJECT, PROJKEY, KEYWORD, MODULE WHERE PROJECT.projectID=PROJKEY.projectID AND KEYWORD.keyID=PROJKEY.keyID AND PROJECT.moduleID='$moduleID' AND KEYWORD.keyword='$keyword'"; //parse the statement $qry_statement = OCIParse ($connection, $query); //or die ("Couldn't parse statement"); //execute the query statement OCIExecute($qry_statement); //or die ("Couldn't execute query"); //echo "<table align=\"center\" border=\"1\" cellpadding=\"8\" cellspacing=\"2\" bgcolor=\"silver\">"; //echo " <tr valign=\"center\"><th>ORIGINATOR</th><th>TITLE</th><th>PROJECT NUMBER</th><th>AVAILABILITY</th><th>SPECIAL //SKILLS</th></tr> //retrieve the results of the query statement and present them in the following way while (ocifetch($qry_statement)) { echo "The Originator is:" .OCIresult($qry_statement, 'ORIGINATOR'); echo "The title is:" .OCIresult($qry_statement, 'TITLE'); echo "The projectID is: ". OCIresult($qry_statement, 'PROJECTID'); echo "The availabilty is: ". OCIresult($qry_statement, 'AVAILABILITY'); echo "The special skills are: ". OCIresult($qry_statement, 'SPECIALSKILLS'); //echo "<tr align =\"center\"><td>" .OCIresult($qry_statement, 'ORIGINATOR'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'TITLE'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'PROJECTID'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'AVAILABILITY'). "</td></tr>"; //echo "<tr align=\"center\"><td>" .OCIresult($qry_statement, 'SPECIALSKILLS'). "</td></tr>"; } //log off the database OCILogoff ($connection); } ?> <div align="center"> <pre> <a href = "http://www.aber.ac.uk">Return to UWA Home Page</a> </div> <div align="center"> <pre> <a href = "http://www.aber.ac.uk/compsci">Return to Computer Science Home Page</a> </pre></div> <div align="center"> <pre> <a href = "mainMenu.html">Return to Project Database Main Menu</a> </pre></div> </body> </html>