horseatingweeds Posted August 15, 2007 Share Posted August 15, 2007 I can't figure out what I'm doing wrong. Does anyone see what I'm doing wrong with this update inquiry? All of the code works elsewhere except the update inquiry, I think that's where the problem is. $username = 'testname3'; $title = strip_tags($_POST['title_u']); $email = strip_tags($_POST['email_u']); $phone = strip_tags($_POST['phone_u']); $state = strip_tags($_POST['state_u']); $availability = strip_tags($_POST['availability_u']); $description = strip_tags($_POST['description_u']); $linkID = @mysql_connect('localhost', 'root', 'pasyes') or die('Could not connect'); @mysql_select_db('breederlist') or die ('Could not get DB'); $query = "UPDATE listing SET title='$title', email='$email', phone='$phone', state='$state', availability='$availability', description='$description' WHERE rowID='$username'"; $result = mysql_query($query); if ($result) echo $username . " updated."; else echo "Trouble updating"; Quote Link to comment https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/ Share on other sites More sharing options...
lemmin Posted August 15, 2007 Share Posted August 15, 2007 Is there an error message? What is not working about it? Quote Link to comment https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/#findComment-325129 Share on other sites More sharing options...
horseatingweeds Posted August 15, 2007 Author Share Posted August 15, 2007 It echos my error message 'trouble updating.' The database connection works. If I replace the update query with another query, like this one: $query = "INSERT INTO listing SET username='$username', title='$title', email='$email', phone='$phone', state='$state', availability='$availability', description='$description'"; It works fine. Quote Link to comment https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/#findComment-325143 Share on other sites More sharing options...
BlueSkyIS Posted August 15, 2007 Share Posted August 15, 2007 try this? $result = mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/#findComment-325144 Share on other sites More sharing options...
horseatingweeds Posted August 15, 2007 Author Share Posted August 15, 2007 It gives me this: Unknown column 'rowID' in 'where clause' Quote Link to comment https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/#findComment-325151 Share on other sites More sharing options...
horseatingweeds Posted August 15, 2007 Author Share Posted August 15, 2007 OOO, that mysql_error() function helped. i misunderstood something and used rowID as if it where part of Updating. It should be WHERE username='username' Quote Link to comment https://forums.phpfreaks.com/topic/65140-trouble-upadating-a-mysql-row/#findComment-325161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.