php - Table will not update, however showing successful -
I'm new to MYSQL
When I try to update a database, then The result appears to be successful, but the item is not showing. Can someone please help me by changing the post in a session variable, trying to take it, but there was no difference.
update_ac.php
$ name = $ _POST ['name']; $ Last name = $ _POST ['review']; // Connect to the server and select the database. Mysql_connect ("$ host", "$ username", "$ password") or die ("can not connect"); Mysql_select_db ("$ db_name") or die ("can not choose DB"); // update data in mysql database $ sql = "Review SET name = '$ name', review = '$ lastname' WHERE id = '$ id'"; $ Result = mysql_query ($ SQL); // If successfully updated ($ result) {echo "successful"; Echo "& lt; BR & gt;"; Echo "& lt; a href = 'list_reviews.php' & gt; View Results & lt; / a & gt;"; } And {echo "error"; Echo "welcome" $ _POST ['name']. "& Lt; br / & gt;"; Echo $ lastname; }? & Gt; Connect to the server and select database Mysql_connect ("$ host", "$ username", "$ password ") Or die (" Can not connect "); Mysql_select_db ("$ db_name") or die ("can not choose DB"); // The value of the received ID was sent from the address bar $ id = $ _ GET ['id']; // Recover data from database $ sql = "SELECT * FROM $ tbl_name WHERE id = '$ id'"; $ Result = mysql_query ($ SQL); $ Rows = mysql_fetch_array ($ result); ? & Gt; & Lt ;? Php includes "include / header.php"; ? & Gt; & Lt; Div id = "bodywrap" & gt; & Lt; Div id = "leftcol" & gt; & Lt; H1 & gt; Update form & lt; / H1> & Lt; Form name = "form1" method = "post" action = "update_ac.php" & gt; & Lt; Label & gt; Name & lt; / Labels & gt; & Lt; Input name = "name" type = "article" id = "name" value = "& lt;; echo $ rows ['name'] ;;>" & Gt; & Lt; Br / & gt; & Lt; Label & gt; Review & lt; / Labels & gt; & Lt; Input name = "lastname" type = "text" id = "lastname" value = "& lt;? $ Rows ['review'];; & gt; size =" 15 ">
; & Lt; input name = "id" type = "hidden" id = "id" value = "& lt;? Echo $ rows ['id'] ;; & Gt; ">
Input Type =" submit "name =" submit "value =" submit "> & lt ; Php // Close connection mysql_close ();? & Gt;
Did you note that you have $ id and $$ _POST [' Id '] or $ _REQUEST [' id '] or $ _GET [' id ']? It is missing:
$ id = $ _POST [' id '];
SQ works because it can be found on every ID = 'DID update' It is therefore not an error.
In addition, as mentioned by others, use mysqli, the Mysql extension is dangerous and will probably be boycotted soon.
Comments
Post a Comment