Help!!
Moderator: General Moderators
- potato
- Forum Contributor
- Posts: 192
- Joined: Tue Mar 16, 2004 8:30 am
- Location: my lovely trailer, next to the big tree
Help!!
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!');
$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!');
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!');
Last edited by PrObLeM on Tue Mar 16, 2004 4:49 pm, edited 1 time in total.
-
coreycollins
- Forum Commoner
- Posts: 67
- Joined: Sun Feb 01, 2004 1:04 pm
- Location: Michigan
Try putting commas between each item.
For example:
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!');-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
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.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
then again, many people aren't as thoughtless as I :)
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
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