Jump to content

[SOLVED] MYSQL Replace error.


JasonO

Recommended Posts

Hi.

 

Is there anything wrong with this syntax? I get an error and it refuses to work :S

 

mysql_query("REPLACE INTO currentcust WHERE id=$cust_id
(id, name, email) VALUES ('$cust_id', '$cust_name', '$cust_email') ")
or die(mysql_error());

 

The 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 'WHERE id=34 (id, name, email) VALUES (34,' at line 1

 

All the variables are right and contain the correct values.

 

Any ideas?

 

Thanks,

JasonO :)

Link to comment
https://forums.phpfreaks.com/topic/56805-solved-mysql-replace-error/
Share on other sites

I've never heard of any REPLACE function in mySQL. There is however and UPDATE function. Perhaps you are trying to do that?

 

Try this:

 

mysql_query("UPDATE currentcust SET id = '$cust_id', name = '$cust_name', email = '$cust_email' WHERE id=$cust_id") 
or die(mysql_error());  

 

EDIT:

 

Ok, try this:

 

mysql_query("REPLACE INTO currentcust (id, name, email) VALUES ('$cust_id', '$cust_name', '$cust_email') WHERE id='$cust_id'")
or die(mysql_error());

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.