I am trying to update my database when a page is visited.
Here is my code
<?php
$con = mysql_connect("localhost","xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxx", $con)or die( "Unable to select database");
$id=$_GET["q"];
$sql="UPDATE audit SET lks =lks+1 WHERE id='$id'" or die(mysql_error());
?>
The database does not update at all?
Can anyone help?
you are not actually executing the query:
<?php
$con = mysql_connect("localhost","xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxx", $con)or die( "Unable to select database");
$id=$_GET["q"];
$sql="UPDATE audit SET lks =lks+1 WHERE id='$id'";
mysql_query($sql) or die(mysql_error());
?>
You never query the sql statement.
mysql_query($sql);
And I wouldn't suggest using the mysql_* library, it's deprecated and isn't as secure as something like PDO or mysqli