Forum Moderators: coopster
<html>
<head>
<title></title>
</head><?
$host = "localhost";
$user = "user";
$pass = "password";
$dbname = "database";$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);$query= "select * from 4images_images where image_id='" . $_POST['image'] . "'";
$result= mysql_query($query);
$row = mysql_fetch_array($result);
$filename=$row['image_media_file'];
$category=$row['cat_id'];$file="http://www.url.com/4images/data/media"."/".$category."/".$filename;
echo "<p><a href=\"$file\">Download File</a></p>";
echo "<p><a href=\"http://url.com\">Back</a></p>";
echo" </body>";
echo" </html>";
?>
I want to update my database, by increasing the value by one from table 4images_images on field image_hits. The line should be:
UPDATE 4images_Images SET 4images_Hit=4Images_Hit + 1 WHERE Image_ID="Blah blah";
but where do i put it? Thanks for helping.
<html>
<head>
<title></title>
</head><?
$host = "localhost";
$user = "user";
$pass = "password";
$dbname = "database";$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);$query= "select * from 4images_images where image_id='" . $_POST['image'] . "'";
$result= mysql_query($query);
$row = mysql_fetch_array($result);
$filename=$row['image_media_file'];
$category=$row['cat_id'];UPDATE 4images_Images SET 4images_Hit=4Images_Hit + 1 WHERE Image_ID="Blah blah";
$file="http://www.url.com/4images/data/media"."/".$category."/".$filename;
echo "<p><a href=\"$file\">Download File</a></p>";
echo "<p><a href=\"http://url.com\">Back</a></p>";
echo" </body>";
echo" </html>";
?>
Is this right then? Thank you.
$query1 = "UPDATE 4images_Images SET 4images_Hit=4Images_Hit + 1 WHERE Image_ID='Blah blah'";
$uptest = mysql_query($query1);
same as usual, you put the query into a variable and then use the mysql_query function to send the query to mysql.
now $uptest would be true if the query succeeded and false if it didn't. You can handle this as well if you need to. It will at least help while debugging during development.
if ($uptest) {
echo "<p>update query successful!";
} else {
echo "<p>update failed";
}