The following is a PHP code to edit a line in a MySQL table.
Lots of things do not work in this code. To start with is the following warning message I get when start running it:
“Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\magar\xxx.php on line 16”.
Second is: I do not manage to delete the table when start running. Why is that ?! Evrey time I run it an additional line emerges!
Third: Clicking “Edit”, the existing value of: “Name” shows up at the input editing box. Trouble is: instead of showing: “aaa aaa aaa”
only “aaa” shows up. The rest of the string, apart from the the segment which ends at first space, is not shown ! Why?!
I wish someone could help me with that complication!
Thanks in advance!
You are missing quotes around the value in the html markup, so the first space character in the value is a stop character.
You should not have to do this,
mysqli_query($db, “DROP TABLE IF EXISTS ‘xxx’;”);
mysqli_query($db, “CREATE TABLE xxx(name VARCHAR(128))”);
mysqli_query($db, “INSERT INTO xxx(name) VALUES(‘aaa aaa aaa’)”);[/php]
Tables should be created once, not every time.
Use prepared statements.
[php]$edid=mysqli_query($db, “SELECT * FROM xxx WHERE name = $name”);[/php]
Has an error in it.