February 14th, 2013, 07:41 AM
UPDATE mysql table data using form
Good day guys im new here in you community, first of all im a noob in building website and php code, I just learn on google by reading tutorials and experiment by try and error.
So i had this a problem with this tutorial
http: //w w w . phpeasystep. com /mysql/9. html
Because i want to have a Edit button on my row. I connect the table and mysql perfectly and all script is working, but after i replace the old one nothing happens, it doesnt update the mysql table. but after i send the Submit button it saids "Successfully". but i check my table nothing happen.
I search on google for some related topic i see some errors on connecting id but im sure i have a hidden input for id for the step 4 .
This is the code for my update
update data in mysql database
$sql="UPDATE $tbl_name SET name='$name', lastname='$lastname', email='$email' WHERE id='$id'";
and this is sample form and get the value in my mysql table
<input name="name" type="text" id="name" value="<? echo $rows['name']; ?>">
Im willing to cooperate thanks.
February 14th, 2013, 08:00 AM
As a noob STOP!!! DO NOT use the deprecated MySQL extensions. Switch to PDO. It makes no sense to learn PHP using obsolete techniques.
Did you echo your query to make sure it contains what you expect? Where is your error checking code?
P.S. Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum. Also read ManiacDan's New User Guide for debugging techniques and common problems.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
February 14th, 2013, 08:48 AM
apart from what gw1500se already said about the obsolete database functions:
I'm sorry to say, but this whole tutorial is garbage -- like so many online tutorials. It's a horrible collection of security holes, bad techniques and a programming style from the 90s. So this really isn't something you wanna learn from, let alone use it as a template for your website.
If you're looking for good tutorials, I've found this to be one:
Specifically for databases, there's also this wiki:
Also check the thread in my signature, which is a collection of typical security holes (your code already has two of them). When you know the "dangers" of web programming, it will also be easier for you to tell good tutorials and the terrible ones apart. For example, whenever you see variables being inserted directly into query strings, you know you should better leave that website.
Last but not least, use the official manual. It has first-hand info and will also warn you of obsolete functions and security issues. For example, the mysql_ functions all have a big red warning telling you that this extension is deprecated and will be removed sooner or later:
February 14th, 2013, 09:43 AM
Thanks! now im aware what to read and what to learn.
Originally Posted by gw1500se
February 14th, 2013, 09:47 AM
Thanks for the links ill bookmark them, and start learning them.
Originally Posted by Jacques1
Comments on this post
February 14th, 2013, 09:57 AM
Originally Posted by raijinlee
Comments on this post