Forum Moderators: coopster
So I have the following code (the id is stored in the url)
<?php
$conn = mysql_connect("localhost", "host", "pw");
$db = mysql_select_db("datbase");
$id = $_GET['id'];
$sql= "update user_mail set read= 1 where id= $id";
$result= mysql_query($sql);
?>
Next thing is to check the value of mysql_affected_rows following your query. Remember that affected rows will be zero if there is no _acutal_ change to the row (i.e. the value was already set to "1".)
Alternatively, when faced with a stubborn query I usually head straight into Webmin (I don't know if phpMyAdmin allows direct SQL query) and check it from there).
You can also enter the query directly into the mysql binary if you're on *nix.
// Lets start with the page counter, get and update...
$result = mysql_query("SELECT * FROM pages WHERE name='$page'");
$page = mysql_fetch_object($result);
mysql_query("UPDATE pages SET count=count+1 WHERE name='$page->name' LIMIT 1");
No doubt it can be improved on, but it works (and I did verify that in phpMyAdmin ;-P )