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'; ?> Quote 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. Quote 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 Quote 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 Quote 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'; ?> Quote 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. Quote 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 Quote 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' Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.