Jump to content

Trying to delete a database row via PHP


jake_ms

Recommended Posts

Hi all, its giving me a parse error but I'm not too sure where the mistake is? Could someone please take a look and explain where I've gone wrong? Thanks very much

 

$staffno = $_POST["staffnodelete"];

IF ($staffnodelete=="" )

{print "You have deleted $staffname  ";}

 

putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin");

$con = OCILogon("username","password","DB");

 

 

$query = ("Delete from Staff where staffno = $staffnodelete");

//(" . $name . ")"

 

$stmt = OCIParse($conn, $query) or die ('Can not parse query');

OCIBindByName($stmt,":var_no", &$no,50) or die ('Can not bind variable');

OCIExecute($stmt, ":var_no", &$name,50) or die ('Can not Execute statement');

OCIFreeStatement($stmt);

OCILogoff($con);

echo "$no";

 

Link to comment
https://forums.phpfreaks.com/topic/47732-trying-to-delete-a-database-row-via-php/
Share on other sites

You're trying to bind 2 variables to the oracle placeholder :var_no.  And with the second one you're calling ociExecute instead of ociBindByName.

 

Try replacing

OCIBindByName($stmt,":var_no", &$no,50) or die ('Can not bind variable');
OCIExecute($stmt, ":var_no", &$name,50) or die ('Can not Execute statement');

 

with

 

OCIBindByName($stmt,":var_no", $no, -1) or die ('Can not bind variable'); // <-- repeat this for each variable.  Each one should have a different place holder.
OCIExecute($stmt) or die ('Can not Execute statement');

 

Might help if you specify which line you get the parse error on and the actual error message.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.