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? 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? 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 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. 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 :( Link to comment https://forums.phpfreaks.com/topic/14740-mysql-value-not-updating/#findComment-58835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.