Jump to content

[SOLVED] PHP INSERT error...What???


resdog

Recommended Posts

Hello everyone. Had a bit of a stumper to me, maybe someone can help. I have a basic php site, with a MySQL database. The database has a table, "vendortrack", and the rows are "refnum ,order ,tracking ,shipcost ,dateshipped". I'm trying to do a simple INSERT INTO php command with posted variables, as follows:

 

$q = "INSERT INTO vendortrack (refnum, order, tracking, shipcost, dateshipped)
			VALUES ('$refnum','$order','$tracking','$shipcost','$todaysDate')";
$result = mysql_query($q)
	or die(mysql_error());

 

When I run this on the server, I get this error:

 

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 'order ,tracking ,shipcost ,dateshipped) VALUES ('ddf','2252','1Zkdikd','2.25' at line 1

 

I don't see what is wrong. So I went to PHP MyAdmin and ran a smiliar query to see what the SQL looked like. Everything was the same, except there are these weird kind of quotes around the rows:

 

`refnum` ,`order` ,`tracking` ,`shipcost` ,`dateshipped`

 

They aren't the apostrophe character, but I don't know what they are (apostrophe: '  that other character: `  . I replaced that line with the line from phpMyAdmin, and the script works great! I've never had to add the quote things before when I did INSERT INTO, I've just had to name the rows. Does anyone see what my problem is, or what those apostrophe looking characters are? Thanks in advance for your help!

Link to comment
https://forums.phpfreaks.com/topic/111674-solved-php-insert-errorwhat/
Share on other sites

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.