Need help with my truncate table function
Posted: Tue Apr 07, 2009 2:25 pm
Hi,
I have the following bit of PHP. I'm trying to truncate a table called tbl_demo in my demo db.
This is my confirm query function which is in another file that I include.
I keep getting this error message
How can I truncate my table and check that it was successful. I am new to php so really appreciate your help.
I have the following bit of PHP. I'm trying to truncate a table called tbl_demo in my demo db.
Code: Select all
<?php
//This will be used to drop and create the image table
//and reload the images into the table
echo "Truncating Demo table...";
$query = "TRUNCATE TABLE ".DB_NAME . ".tbl_demo";
$result = mysql_query ($query, $connection);
confirm_query($result);
if(mysql_fetch_array($result)){
echo "Table Truncated";
}
?>Code: Select all
function confirm_query($result_set) {
if (!$result_set) {
die("Database query failed: " . mysql_error());
}
}Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
How can I truncate my table and check that it was successful. I am new to php so really appreciate your help.