...

View Full Version : delete query does not work in php script (resolved)



bfsog
09-21-2005, 01:40 AM
I am trying to delete rows from a database if a column of that row's date is 2 days old.

I echo out the variable and run it through PHPMyAdmin and it works, however, through the php script nothing happens, no errors, all it does it displays the variable.

Anyone any ideas?



<?php

include("includes/conn.php");

$today = date("d/m/Y", strtotime("-2 day"));
$del = "DELETE FROM users WHERE signup_date = '$today'";
echo $del;
$query = mysql_query("DELETE FROM users WHERE signup_date = '$today'") or die(mysql_error());
if (mysql_affected_rows() > 0) {
echo (mysql_affected_rows);
}

?>


Thanks in advance

Nightfire
09-21-2005, 02:01 AM
$query = mysql_query("DELETE FROM users WHERE signup_date = '$today'") or die(mysql_error());
if (mysql_affected_rows($query) > 0) {
echo mysql_affected_rows($query);
}


You need to give the mysql_effected_rows a variable/query to run itself against, which you hadn't done



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum