lmhart Posted October 12, 2009 Share Posted October 12, 2009 I can not get the following code to work. If I run the sql statement in the db it will delete all the data but it will not work from the page. My connection string is fine I just can not get it to delete. <?php include 'dbc.php' mysql_query("delete from categories"); include 'redirect_category.php'; ?> Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/ Share on other sites More sharing options...
pastcow Posted October 12, 2009 Share Posted October 12, 2009 try "truncate table categories" it might also be worth displaying echo(mysql_error()) after it just to see if there is anything going wrong. Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935569 Share on other sites More sharing options...
lmhart Posted October 12, 2009 Author Share Posted October 12, 2009 changed to truncate table but still getting the following error Parse error: syntax error, unexpected T_STRING in /home/themarkh/public_html/budget/delete_all_categories.php on line 5 Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935587 Share on other sites More sharing options...
mikesta707 Posted October 12, 2009 Share Posted October 12, 2009 post code. a syntax error is usually easy to fix Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935589 Share on other sites More sharing options...
lmhart Posted October 12, 2009 Author Share Posted October 12, 2009 <?php include 'dbc.php' mysql_query("Truncate table 'categories'"); include 'redirect_category.php'; ?> Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935591 Share on other sites More sharing options...
cags Posted October 12, 2009 Share Posted October 12, 2009 Remove the single quotes which you have around the word categories. Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935595 Share on other sites More sharing options...
lmhart Posted October 12, 2009 Author Share Posted October 12, 2009 still getting the same error Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935597 Share on other sites More sharing options...
cags Posted October 12, 2009 Share Posted October 12, 2009 You also don't have a semicolon on the end of include 'dbc.php' Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-935598 Share on other sites More sharing options...
lmhart Posted October 13, 2009 Author Share Posted October 13, 2009 You also don't have a semicolon on the end of include 'dbc.php' That was it. Thanks Link to comment https://forums.phpfreaks.com/topic/177444-solved-delete-all-from-a-table/#findComment-936296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.