Jump to content

Mysql value not updating?


fert

Recommended Posts

[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
Share on other sites

[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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.