Page 1 of 1

Help!!

Posted: Tue Mar 16, 2004 4:12 pm
by potato
Does somebody sees the fault in this query?


$query = mysql_query("UPDATE bands SET band_name='$name' band_hoofdgenre='$genre' band_subgenre='$subgenre' band_location='$location' band_website='$website' band_info='$info' WHERE band_id='$bandid'")or exit('Not updated!');

Posted: Tue Mar 16, 2004 4:30 pm
by phuts
Try it without the quotes around $bandid

Posted: Tue Mar 16, 2004 4:30 pm
by tim
seems like you should use INSERT instead of UPDATE

Posted: Tue Mar 16, 2004 4:33 pm
by PrObLeM
try this

Code: Select all

$query = mysql_query("UPDATE bands SET band_name='".$name."', band_hoofdgenre='".$genre."', band_subgenre='".$subgenre."', band_location='".$location."', band_website='".$website."', band_info='".$info."' WHERE band_id='".$bandid."'")or exit('Not updated!');

Posted: Tue Mar 16, 2004 4:35 pm
by coreycollins
Try putting commas between each item.
For example:

Code: Select all

$query = mysql_query("UPDATE bands SET band_name='$name', band_hoofdgenre='$genre', band_subgenre='$subgenre', band_location='$location', band_website='$website', band_info='$info' WHERE band_id=$bandid")or exit('Not updated!');

Posted: Tue Mar 16, 2004 4:43 pm
by phuts
tim wrote:seems like you should use INSERT instead of UPDATE
tim makes a good point. Are you trying to enter new data or change already existing data?

Posted: Tue Mar 16, 2004 4:51 pm
by potato
Allright, i found it.

It were the commas that i forgot.

Thanx everybody

Posted: Tue Mar 16, 2004 5:08 pm
by Illusionist
1 question to tim and phuts: how could he insert new data into an existing band_id?? He is obviously trying to edit existing data, or else there would be no need for the WHERE clause

Posted: Tue Mar 16, 2004 5:17 pm
by phuts
Illusionist wrote:1 question to tim and phuts: how could he insert new data into an existing band_id?? He is obviously trying to edit existing data, or else there would be no need for the WHERE clause
who knows.. but I do things like that all the time, usually because I forget the syntax / feel lazy and copy some code I've already typed. Sometimes I end up completely forgetting my original intent after making such a mistake (ie updating versus inserting). granted a WHERE clause in this code should be a redflag, but i could see myself having forgotten what exactly it is I was trying to do, so maybe it happens to others.

then again, many people aren't as thoughtless as I :)

Posted: Tue Mar 16, 2004 7:00 pm
by tim
if he would have clarified that he was intending to 'edit' using the sql statement, i wouldnt have bothered refering the INSERT command. I dont assume certain things, yes the WHERE clause is a good hint the statement was for editing purposes, but no offsense to bev he might not of known any better.

By the quick glance, he looked like he was adding data, just the way I see things when I glance over it.

my fault, apologies