refiking Posted March 21, 2008 Share Posted March 21, 2008 When I run this, I don't get any errors and the db is not updated. What do I need to change? $sql2= mysql_query("UPDATE gridgamers SET pass = '$password' WHERE user = '$username'")or die(mysql_error()); $sql3= mysql_query("UPDATE gridgamers SET pc = 'yes' WHERE user = '$username'")or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/97275-database-wont-update/ Share on other sites More sharing options...
papaface Posted March 21, 2008 Share Posted March 21, 2008 You're not running the queries, you're just storing them in variables. An example of running them would be: $sql2= mysql_query("UPDATE gridgamers SET pass = '$password' WHERE user = '$username'")or die(mysql_error()); $sql3= mysql_query("UPDATE gridgamers SET pc = 'yes' WHERE user = '$username'")or die(mysql_error()); if ($sql2) { echo "query ran sucessfully"; } Link to comment https://forums.phpfreaks.com/topic/97275-database-wont-update/#findComment-497782 Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 actually they are running the query and returning the query resource to a variable ($sql2, $sql3) they are not updating because there must be no rows where user = $username Its better to write your query like <?php $q = "UPDATE `gridgamers` SET pass = '".$password."' WHERE user = '".$username."'"; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); #if it fails no error try echo $q; ?> take th echo $q to phpmyadmin and see what u get Link to comment https://forums.phpfreaks.com/topic/97275-database-wont-update/#findComment-497787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.