PHP button delete row from table not working

SonDang

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.!

http://pastebin.com/9Zz217Bn

Matthew Brown aka Lord Matt

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Delete row from database with a button in table (PHP)

From Dev

Delete a table row is not working with jquery on button click

From Dev

Delete button in not working on table

From Dev

Delete row from table on corresponding delete button click

From Dev

Delete element from table by id with button php

From Dev

Delete mysql Table row by clicking submit button php

From Dev

PHP form delete from MYSQL table dont delete the right row

From Dev

Delete a row from table view using custom button - Swift 3

From Dev

JQuery - Delete table row if delete button is clicked

From Dev

Beginner: Delete row from Table and Database PHP/HTML/MySQL

From Dev

Delete row from DataGridView via button on the row

From Dev

Delete a row from Parse Table

From Dev

Delete a row from sqlite table

From Dev

Delete row from dynamic table

From Dev

How to delete the table row on button click

From Dev

Delete the table row of the Last Triggered Button jQuery

From Dev

Add edit/delete button at the end of the table row

From Dev

How to delete row of table with a button inside

From Dev

quiz next button not working when a json row is delete using php and jquery/javascript

From Dev

DELETE * FROM TABLE WHERE this=that not working

From Dev

Inserting delete button for each table not working

From Dev

Error Delete row from php

From Dev

Delete row from a XML in PHP

From Dev

PHP/SQL Delete button for each row

From Dev

Delete row from table conditional on a related table

From Dev

Table row data delete on Action Sheet Delete Button Pressed

From Dev

Delete Button in PHP isn't Working

From Dev

Add/Delete row dynamically to/from jquery table using angularjs not working properly

From Dev

how to delete the specified row from html table and also in mysql table using php

Related Related

  1. 1

    Delete row from database with a button in table (PHP)

  2. 2

    Delete a table row is not working with jquery on button click

  3. 3

    Delete button in not working on table

  4. 4

    Delete row from table on corresponding delete button click

  5. 5

    Delete element from table by id with button php

  6. 6

    Delete mysql Table row by clicking submit button php

  7. 7

    PHP form delete from MYSQL table dont delete the right row

  8. 8

    Delete a row from table view using custom button - Swift 3

  9. 9

    JQuery - Delete table row if delete button is clicked

  10. 10

    Beginner: Delete row from Table and Database PHP/HTML/MySQL

  11. 11

    Delete row from DataGridView via button on the row

  12. 12

    Delete a row from Parse Table

  13. 13

    Delete a row from sqlite table

  14. 14

    Delete row from dynamic table

  15. 15

    How to delete the table row on button click

  16. 16

    Delete the table row of the Last Triggered Button jQuery

  17. 17

    Add edit/delete button at the end of the table row

  18. 18

    How to delete row of table with a button inside

  19. 19

    quiz next button not working when a json row is delete using php and jquery/javascript

  20. 20

    DELETE * FROM TABLE WHERE this=that not working

  21. 21

    Inserting delete button for each table not working

  22. 22

    Error Delete row from php

  23. 23

    Delete row from a XML in PHP

  24. 24

    PHP/SQL Delete button for each row

  25. 25

    Delete row from table conditional on a related table

  26. 26

    Table row data delete on Action Sheet Delete Button Pressed

  27. 27

    Delete Button in PHP isn't Working

  28. 28

    Add/Delete row dynamically to/from jquery table using angularjs not working properly

  29. 29

    how to delete the specified row from html table and also in mysql table using php

HotTag

Archive