Page 1 of 1

UPDATE ALL COLUMNS?

Posted: Thu Aug 09, 2007 6:39 pm
by phpretard
I am trying to update every field in the table.

I don't know what to put after "SET" to indicate all columns.

What you see after "SET <<<<<HERE>>> = " is the replacement info coming from a form.

Code: Select all

mysql_connect("localhost","$username","$password");
@mysql_select_db($database) or die( "Unable to select database");

("update name_list set name='$name' where id='$row[id]'");

$query = "UPDATE wanted  SET    <<<<<HERE>>>    = ('$name','$last','$middle','$dob','$alialses','$race','$age','$sex','$height'
,'$weight','$marks','$street','$city','$state','$zip','$make','$model','$summary','$hair','$eyes','$piclink') WHERE id=1";
mysql_query($query);


Re: UPDATE ALL COLUMNS?

Posted: Thu Aug 09, 2007 6:59 pm
by Christopher
The syntax for UPDATE is:

Code: Select all

$query = "UPDATE wanted  SET name='$name',last='$last',middle='$middle',dob='$dob',aliases='$alialses' WHERE id=1";
mysql_query($query);


Posted: Thu Aug 09, 2007 7:06 pm
by phpretard
Does it have to go in order?

Posted: Thu Aug 09, 2007 7:10 pm
by Christopher
The order does not matter because they are individual associations. In this way it is different than the INSERT/REPLACE syntax. Although you can use this SET syntax for INSERT/REPLACE with some databases.

Posted: Thu Aug 09, 2007 7:15 pm
by phpretard
This doesn't work, but it doesn't give me an error.


Code: Select all

$query = "UPDATE wanted SET name='$name',last='$last',middle='$middle',dob='$dob',aliases='$aliases',race='$race',age='$age',
sex='$sex',height='$height',weight='$weight',marks='$marks',street='$street',city='$city',state='$state',zip='$zip',
make='$make',model='$model',summary='$summary',hair='$hair',eyes='$eyes',picklink='$piclink') WHERE id=1";
mysql_query($query);

Any thoughts?

I populated the table with all the same code. The only thing I have changed is what you see.

Posted: Thu Aug 09, 2007 8:12 pm
by Zoxive
phpretard wrote:This doesn't work, but it doesn't give me an error.

Any thoughts?

I populated the table with all the same code. The only thing I have changed is what you see.

Code: Select all

$query = "UPDATE wanted SET name='$name',last='$last',middle='$middle',dob='$dob',aliases='$aliases',race='$race',age='$age',
sex='$sex',height='$height',weight='$weight',marks='$marks',street='$street',city='$city',state='$state',zip='$zip',
make='$make',model='$model',summary='$summary',hair='$hair',eyes='$eyes',picklink='$piclink') WHERE id=1";
mysql_query($query) or die('Mysql Error : <br>' . $query . '<br>' . mysql_error());

Oh?

Posted: Thu Aug 09, 2007 8:24 pm
by phpretard
Thank you.

(I do have a name to live up to.)