3raser Posted April 7, 2011 Share Posted April 7, 2011 I've tried mysql_error(), yet nothing is displayed, but I'm pretty sure it may be something wrong with my query. After someone inputs their new information, site title in the database is changed to 0, and description isn't updated at all.., but it's still the same data as before and isn't changed. if(!$_POST['title'] || !$_POST['description']) { echo " <table><form action='account.php' method='POST'> <input type='hidden' name='edit' value='1'> <tr><td>Site Name</td><td><input type='text' name='title' value='". $grab['title'] ."'></td></tr> <tr><td>Site Description</td><td><textarea name='description' rows='18' cols='40' maxlength='550'>". $grab['description'] ."</textarea></td></tr> <tr><td>Finished?</td><td><input type='submit' value='Update Information'></td></tr> </form></table>"; } else { $title = mysql_real_escape_string(strip_tags($_POST['title'])); $description = mysql_real_escape_string($_POST['description']); $to_censor = array("fag", "ass", "asshole", "douchebag", "dumbass"); $new = str_replace($to_censor, "****", $description); $description = strip_tags($new, "<b><i><a>"); mysql_query("UPDATE sites SET title = '$title' AND description = '$description' WHERE username = '". $_SESSION['user'] ."'") or die(mysql_error()); echo "Updated information successfully. <a href='account.php'>Back to My Account</a>"; } Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/ Share on other sites More sharing options...
Pikachu2000 Posted April 7, 2011 Share Posted April 7, 2011 Echo your query string and see if it contains the values you think it should contain. Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198457 Share on other sites More sharing options...
3raser Posted April 7, 2011 Author Share Posted April 7, 2011 Echo your query string and see if it contains the values you think it should contain. The variables are correct. :/ Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198460 Share on other sites More sharing options...
Pikachu2000 Posted April 7, 2011 Share Posted April 7, 2011 I didn't ask if the variables were correct. I said to echo the query string. Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198468 Share on other sites More sharing options...
3raser Posted April 7, 2011 Author Share Posted April 7, 2011 I didn't ask if the variables were correct. I said to echo the query string. Sorry, didn't see the query part. Never knew you could echo a query... Anyways, it returns the number 1. Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198470 Share on other sites More sharing options...
Pikachu2000 Posted April 7, 2011 Share Posted April 7, 2011 Separate the query string from the query execution, and echo the query string so you can make sure it's properly formed. $query = "UPDATE sites SET title = '$title' AND description = '$description' WHERE username = '". $_SESSION['user'] ."'"; $result = mysql_query( $query ); echo $query; Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198474 Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2011 Share Posted April 7, 2011 Your UPDATE query is AND'ing the contents of your `description` field with the value in '$title' and storing that in the `title` column - SET title = '$title' AND description = '$description' The SET term is a comma separate list of column = value pairs. AND is a logical operator. Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198478 Share on other sites More sharing options...
3raser Posted April 7, 2011 Author Share Posted April 7, 2011 Your UPDATE query is AND'ing the contents of your `description` field with the value in '$title' and storing that in the `title` column - SET title = '$title' AND description = '$description' The SET term is a comma separate list of column = value pairs. AND is a logical operator. Thank you for that! Quote Link to comment https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198488 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.