Ret denne PHP forespørgsel?
Jeg kører dette script på min database:<?php
$photo = $_POST['Photo_id'];
$album = $_POST['Album_id'];
$getImageCount = mysql_query("SELECT image_count FROM gallery_album WHERE Album_id={$album}") or die(mysql_error());
$row = mysql_fetch_assoc($getImageCount);
$newImageCount = $row['image_count'] - 1;
echo "CALC:";
echo $getImageCount - 1;
echo "CALCUlATED:";
echo $newImageCount;
echo "VAR:";
echo $row['image_count']-1;
mysql_query("DELETE FROM gallery_photos WHERE Photo_id={$photo}") or die(mysql_error());
mysql_query("UPDATE gallery_album SET image_count={$newImageCount} WHERE Album_id={$album}") or die(mysql_error());
?>
Men $row['image_count'] returnerer ingenting? Dette ser jeg ved endt forespørgsel:
CALC:6CALCUlATED:-1VAR:-1
Hvad dælen kan være galt?