fert Posted July 16, 2006 Share Posted July 16, 2006 [code] $cn=@mysql_connect("","","") or die(mysql_error()); @mysql_select_db("",$cn) or die(mysql_error()); $result=@mysql_query("SELECT num FROM views",$cn) or die(mysql_error()); while($row=mysql_fetch_array($result)) { $num=$row[num]; } $num++; $result=@mysql_query("UPDATE views SET num='$num' WHERE num!='$num'",$cn) or die(mysql_error()); echo "There have been $num views of this page";[/code]When i go back to the page that this is on the value is always 1.what can i do to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/14740-mysql-value-not-updating/ Share on other sites More sharing options...
akitchin Posted July 16, 2006 Share Posted July 16, 2006 what's in num in your database? is there one entry for each page view? Quote Link to comment https://forums.phpfreaks.com/topic/14740-mysql-value-not-updating/#findComment-58832 Share on other sites More sharing options...
fert Posted July 16, 2006 Author Share Posted July 16, 2006 num is the number of views Quote Link to comment https://forums.phpfreaks.com/topic/14740-mysql-value-not-updating/#findComment-58833 Share on other sites More sharing options...
AndyB Posted July 16, 2006 Share Posted July 16, 2006 [code]$result=@mysql_query("UPDATE views SET num='$num' WHERE num!='$num''",$cn) or die(mysql_error());[/code]There's an error in that compounded statement. ... num!='$num' ' = unmatched quotes. The query is failing.When testing, don't use the @ error suppression. Quote Link to comment https://forums.phpfreaks.com/topic/14740-mysql-value-not-updating/#findComment-58834 Share on other sites More sharing options...
fert Posted July 16, 2006 Author Share Posted July 16, 2006 I tried that, but it still doesn't work :( Quote Link to comment https://forums.phpfreaks.com/topic/14740-mysql-value-not-updating/#findComment-58835 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.