gaffer Posted April 18, 2007 Share Posted April 18, 2007 I am trying to add data to a table in oracle but get Warning: ociexecute(): OCIStmtExecute: ORA-00936: missing expression in /homedir/ilex-s02/mrace/public_html/addnewemp.php on line 18 here is the PHP script i am working with, Can anyone see any faults with it? many thanks Gaff. <!--addnewemp.php--> <html><body> <?php putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin"); $conn = OCILogon("UUUUU","PPPPP", "LLLLL"); $StaffNo = $_POST["StaffNo"]; $Firstname = $_POST["Firstname"]; $Surname = $_POST["Surname"]; $Rank = $_POST["Rank"]; $sql = "insert into Staff values ("; $sql = $sql . $Staffno . ",'" . $Firstname . "','" . $Surname . "'," . $Rank . ",'"; $sql = $sql . ")"; $stmt = ociparse($conn, $sql); ociexecute($stmt); ?> Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/ Share on other sites More sharing options...
HaLo2FrEeEk Posted April 18, 2007 Share Posted April 18, 2007 Yes, at the end where you are (I'm assuming) trying to set $sql, don't use that method, use the append equals method: $sql = "insert into Staff values ("; $sql .= $Staffno . ",'" . $Firstname . "','" . $Surname . "','" . $Rank . "'"; $sql .= ")"; $stmt = ociparse($conn, $sql); ociexecute($stmt); Or just do this: $sql = "insert into Staff values (" . $Staffno . ",'" . $Firstname . "','" . $Surname . "','" . $Rank . "')"; $stmt = ociparse($conn, $sql); ociexecute($stmt); Then try it out. Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232508 Share on other sites More sharing options...
gaffer Posted April 18, 2007 Author Share Posted April 18, 2007 basically, we are trying to add 4 values that have been inputted from a previous html page into an oracle database. the html is as follows: <!--- addnewemp.htm ---> <html> <head> <title>Add a new employee </title> </head> <body> <H1>The Personnel System using PHP</H1> Please fill out the form and submit the new employee details:- <hr> <FORM action="addnewemp.php" method="post"> <br>First Name : <input type="text" size="15" name="Firstname"> <br>Surname : <input type="text" size="15" name="Surname"> <br>Staff Number : <input type="text" size="4" name="staffno"> <br>Rank : <input type="text" size="8" name="Rank"> <input type="reset" value="Clear the form"> <input type="submit" value="Submit - enter the data"> </FORM> <hr> </body></html> can you suggest a piece of php script that will allow us to import the input into the oracle database! My life depends on it :'( Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232513 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 18, 2007 Share Posted April 18, 2007 Uhm...I already told you what was wrong with your code, just change what I told you to and try it out. <?php putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin"); $conn = OCILogon("UUUUU","PPPPP", "LLLLL"); $Staffoo = $_POST["staffno"]; $Firstname = $_POST["Firstname"]; $Surname = $_POST["Surname"]; $Rank = $_POST["Rank"]; $sql = "insert into Staff values (" . $Staffno . ",'" . $Firstname . "','" . $Surname . "','" . $Rank . "')"; $stmt = ociparse($conn, $sql); ociexecute($stmt); ?> And btw, unless your life does truly depend on doing this, don't try to increase the urgency of your request by saying it does, its actually annoying, since people will respond to your question on their own time, no matter how urgent it seems. Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232518 Share on other sites More sharing options...
gaffer Posted April 18, 2007 Author Share Posted April 18, 2007 Warning: ociexecute(): OCIStmtExecute: ORA-00936: missing expression in /homedir/ilex-s02/mrace/public_html/addnewemp.php on line 14 Small error there Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232522 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 18, 2007 Share Posted April 18, 2007 I also might let you know that I know nothing about executing oracle queries, I specialize in mysql. I am simply trying to help you with the obvious spelling and query errors. Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232525 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 18, 2007 Share Posted April 18, 2007 What is line 14 in addnewemp.php? Please post at least 2 lines of code before and after line 14 as well, to assist witht he troubleshooting. Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232533 Share on other sites More sharing options...
boo_lolly Posted April 18, 2007 Share Posted April 18, 2007 google man... google.... http://www.orafaq.com/faqphp.htm#USE http://us2.php.net/oracle Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232534 Share on other sites More sharing options...
gaffer Posted April 18, 2007 Author Share Posted April 18, 2007 Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232664 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 18, 2007 Share Posted April 18, 2007 addnewemp.php should be this: <?php putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin"); $conn = OCILogon("UUUUU","PPPPP", "LLLLL"); $Staffno = $_POST["staffno"]; $Firstname = $_POST["Firstname"]; $Surname = $_POST["Surname"]; $Rank = $_POST["Rank"]; $sql = "insert into Staff values ('" . $Staffno . "','" . $Firstname . "','" . $Surname . "','" . $Rank . "')"; $stmt = ociparse($conn, $sql); ociexecute($stmt); ?> Please try that. Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-232674 Share on other sites More sharing options...
gaffer Posted April 19, 2007 Author Share Posted April 19, 2007 thanks from all your help so far.... Part 2 <!--- addnewbook.htm ---> <html> <head> <title>Add a new Book </title> </head> <body> <H1>The Book records System using PHP</H1> Please fill out the form and submit the new Book details:- <hr> <FORM action="addnewbook.php" method="post"> <br>ISBN : <input type="Number" size="11" name="ISBN"> <br>Title : <input type="text" size="15" name="Title"> <br>Author : <input type="text" size="15" name="Author"> <br>Barcode : <input type="Number" size="13" name="Barcode"> <br>PublicationDate : <input type="DATE" size="10" name="PublicationDate"> <br>Publisher : <input type="text" size="20" name="Publisher"> <input type="reset" value="Clear the form"> <input type="submit" value="Submit - enter the data"> </FORM> <hr> </body></html> <!--addnewbook.php--> <html><body> <?php putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin"); $conn = OCILogon("UUUUU","PPPPP", "LLLLL"); $ISBN = $_POST["ISBN"]; $Title = $_POST["Title"]; $AUthor = $_POST["Author"]; $Barcode = $_POST["Barcode"]; $PublicationDate = $_POST["PublicationDate"]; $Publisher = $_POST["Publisher"]; $sql = "insert into Book values ('" . $ISBN . "','" . $Title . "','" . $AUthor . "','" . $Barcode . "','" . $PublicationDate . "','" . $Publisher . "')"; $stmt = ociparse($conn, $sql); ociexecute($stmt); ?> </body></html> i have an error with the date... Warning: ociexecute(): OCIStmtExecute: ORA-01843: not a valid month in /homedir/ilex-s02/public_html/addnewbook.php on line 16 Does the error stat on the html page here <br>PublicationDate : <input type="DATE" size="10" name="PublicationDate"> or is it within the php? Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-233156 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 19, 2007 Share Posted April 19, 2007 I've never heard of the DATE value for the type attribute in input tags, and I messed around in HTML for about 2 years. I could be wrong though. Why not just do a drop down box with the months as the values? Example: <input type="text" size="5" name="PublicationDay" maxlength="2" /> <select name="PublicationMonth"> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" size="5" name="PublicationYear" maxlength="4" /> Then pass this to PHP and convert it to a timestamp using strtotime: <?php $day = $_POST['PublicationDay']; $month = $_POST['PublicationMonth']; $year = $_POST['PublicationYear']; $PublicationDate = strtotime($day . $month . $year); ?> Then pass $PublicationDate to your oracle query, and make sure the table you are inputting to is in either text or date format, though idk if oracle uses the same types as mySQL. Hope this helped. Link to comment https://forums.phpfreaks.com/topic/47617-retreiving-data-and-maintaining-data-urgent/#findComment-233287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.