Jump to content

[SOLVED] SQL syntax?


galvin

Recommended Posts

Maybe this isn't enough info for this question to be answered, but I'll take a shot anyway.  I have the following MySQL query...

 

$query = "INSERT INTO captions (
					cardfile
				) VALUES ('" . $_SESSION['card1'] . "')
				WHERE orderID = " . $_SESSION['orderID'] . " AND card = 1"; 

 

...and every time it runs, I get "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 'WHERE orderID = X AND card = 1' at line 4"

 

It's pulling in the proper value for orderID (it's always a number, I just put an X above) and card, but it keeps giving this error.  Do I have a problem with an extra (or missing) apostrophe or something?

Link to comment
https://forums.phpfreaks.com/topic/139428-solved-sql-syntax/
Share on other sites

I think you mean UPDATE and not ALTER TABLE.

 

INSERT is for new data. ALTER TABLE changes existing data.  it's used like this:

"ALTER TABLE `captions` SET `table_row`='new_data' WHERE `table_row2` = 'check_against_data' AND `card`=1";

way too tired. just woke up when I posted that.

Link to comment
https://forums.phpfreaks.com/topic/139428-solved-sql-syntax/#findComment-729366
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.