funkyapache Posted April 7, 2009 Share Posted April 7, 2009 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. Link to comment https://forums.phpfreaks.com/topic/153045-solved-trying-to-truncate-a-mysql-table-using-php/ Share on other sites More sharing options...
revraz Posted April 7, 2009 Share Posted April 7, 2009 Use mysql_error() after your query. Link to comment https://forums.phpfreaks.com/topic/153045-solved-trying-to-truncate-a-mysql-table-using-php/#findComment-803803 Share on other sites More sharing options...
Mchl Posted April 7, 2009 Share Posted April 7, 2009 What do you want to fetch from TRUNCATE query? It does not return a resultset. Link to comment https://forums.phpfreaks.com/topic/153045-solved-trying-to-truncate-a-mysql-table-using-php/#findComment-803808 Share on other sites More sharing options...
funkyapache Posted April 7, 2009 Author Share Posted April 7, 2009 Use mysql_error() after your query. Thanks thats working brillantly. Link to comment https://forums.phpfreaks.com/topic/153045-solved-trying-to-truncate-a-mysql-table-using-php/#findComment-803821 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.