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
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());

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.