PDA

View Full Version : please help me!


razaksamad
05-08-2008, 06:12 AM
Hi,I am trying to create an update script for my mysql database but cant get the thing to work and recieved an error ::confused:
MySQL said:

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 '(id, name, email) VALUES ('', 'Alias Mohdq', '')' at line 1

Heres the update script (update.php):


$submit=true;
if(isset($submit)){

mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("super") or die(mysql_error());

$sender = $_GET['id'];
$message = $_GET['name'];


if( isset($message)&& $message !== '' ){
$rg_sql = mysql_query("UPDATE alumni (id, name) VALUES ('$sender', '$message')") or die(mysql_error());

}
}

PappaJohn
05-08-2008, 06:22 AM
That's not the proper syntax for UPDATE.

UPDATE syntax (http://dev.mysql.com/doc/refman/5.0/en/update.html)

razaksamad
05-08-2008, 06:36 AM
hai...i am new in php coding...can you help me to write a simple proper syntax....plsss

takin
05-08-2008, 08:17 AM
Try

UPDATE alumni SET id='$sender', name='$message'

There are examples at the link PappaJohn shared if you scroll down a bit.

razaksamad
05-08-2008, 09:09 AM
hai..takin...thanks...it works...but i have a new problem...

MySQL said:

Duplicate entry '0' for key 1

becouse...my mysql have more 20 row of data......plssss:(

takin
05-08-2008, 10:34 AM
I assume that one of these fields is the primary key. You've then told mysql to update every row with the values $sender and $name, but the key must be unique. ie. You can't have $sender in every row because it has to be unique.