Jump to content

[SOLVED] Trying to truncate a mysql table using php.


funkyapache

Recommended Posts

Hi,

 

I have the following bit of PHP. I'm trying to truncate a table called tbl_demo in my demo db.

 

<?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";
  }
?>

This is my confirm query function which is in another file that I include.

function confirm_query($result_set) {
	if (!$result_set) {
		die("Database query failed: " . mysql_error());
	}
}

I keep getting this error message

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.