Bug #16551 Delete Statement not deleting database row data
Submitted: 16 Jan 2006 22:23 Modified: 17 Feb 2006 10:16
Reporter: Lance Adams Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server Severity:S1 (Critical)
Version:mysql-max-5.0.17-osx10.4-powerpc OS:MacOS (Mac OS X 10.4.4)
Assigned to: CPU Architecture:Any

[16 Jan 2006 22:23] Lance Adams
I have a database (items_ordered) with id field as varchar (15), order_num field as int, and qty as int. Example field values are: 6075, 22, 3. When I run the following on the command line I get no errors:
delete from items_ordered where id = '6075' and order_num = '22';

When I run the following from Internet Explorer 6.0.2900.2180 on Windows XP or Safari 2.0.3 on Mac OS X 10.4.4:

//connect to the server and select database
$conn = mysql_connect("localhost", "enter username here", "enter password here") or die(mysql_error());
mysql_select_db("fdi_store",$conn) or die(mysql_error());

if ($_GET[ordernum] != "") {
	$delete_item = "delete from items_ordered where id = '6075' and order_num = '22'";
	mysql_query($delete_item) or die(mysql_error());

//redirect to showcart page
header("Location: shoppingcart.php");

}else {
	//send them somewhere else
	header("Location: store.htm");

I get the following error message:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

How to repeat:
See description

Suggested fix:
[17 Jan 2006 10:16] Aleksey Kishkin

 We do not maintain php. 
If the query works properly from mysql console ( without syntax error), the same query from any client mustn't lead syntax error also. So. i'd suspect php changes query somehow  before sending it to mysql server.

I's suggest to enable mysql log and check what exactly query was sent to mysql from php script.
[18 Feb 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".