I am having the simple php code that shows columns in table test (delete.php & delete_ac.php), when click on delete button this suppose to delete the respective column. But it is displaying error occurred and the table HTML showing blank. Not sure which steps i was wrong. Any help are very appreciated.!
From your responses it seems that you have an error in the sql. The error might be from the way you are sending your data to the script. Tangentially you are encountering an error because you have not in any way checked the input which could be anything and are trusting that it is valid data. It helps to assume that all users are mean and want to cause damage.
So I would recommend at least an if and a test for the data being numeric. Then you could see if you were passing bad data. This might help you troubleshoot and will make your code more robust against attack, user error and things like that. You would not want someone manually typing the URL and putting id=>-1 as that would delete everything.
Like the one you commented:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id']; ?>'' at line 1 mysql version is 5.6.12
However what you might need to do (as others have pointed out) is echo the sql and paste it into something like phpmyAdmin or some MySQL GUI and see what it you get back. The (more than likely) error may help you identify the cause of your problems. It looks like you might have ended up with the php code in the query string.
If you have short tags off then the short php you have use will not work and will end up in the link which it does seem to have done. Try:
<?php echo $rows['id']; ?>
Which I think will work for you much better.
If in doubt go back to the earlier suggestion (not just from me) to echo out the generated sql which I would expect will not look right.
While you are at it can I recommend you consider using "LIMIT 1" at the end of your SQL once you have it working? Then if anything goes wrong you only dropped the one row.
One last thing it makes folks here much happier if you just paste the code into the question.
I hope I helped you.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments