Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deletion Query...

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
I'm really struggling to delete records using the following code. I'm not sure where I'm going wrong... could somebody help me please:

@ $db = mysql_pconnect("home.gov.gg", "username", "password");

if (!$db)
{
echo "Error: Could not connect to the database!";
}

mysql_select_db("database");

$month = date("m");
$day = date("d");
$year = date("Y");
$older = date("Y-m-d", mktime(0,0,0,$month,$day-60-date("w",mktime(0,0,0,$month,$day,$year)),$year));
echo $older;
$query = &quot;DELETE FROM diary WHERE datestart<'&quot;.$older.&quot;'&quot;;
$ExecuteDeletion = mysql_query($query);
mysql_close($db);
 
chage the query to this:

$query = &quot;DELETE FROM diary WHERE datestart<$older&quot;;


hth


Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanks Bastien. I've tried that though and it still doesn't delete. Is the date format correct for MySql?
 
try echoing the query to see if it looks okay...maybe test it through phpmyadmin... Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Ah, problem solved. The IT specialists in the office kindly put read-only rights on the table. It's nice of them to tell me that they were making changes like this on the server.

As you can see, we are running an organized, well oiled machine here... ;o)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top