Discuss UPDATE mysql table data using form in the PHP Development forum on Dev Shed. UPDATE mysql table data using form PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Posts: 3
Time spent in forums: 25 m 11 sec
Reputation Power: 0
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'";
$result=mysql_query($sql);
and this is sample form and get the value in my mysql table
Posts: 2,867
Time spent in forums: 1 Year 1 Week 5 Days 9 h 6 m 6 sec
Reputation Power: 581
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.
Posts: 1,834
Time spent in forums: 1 Month 2 Weeks 1 Day 1 h 44 m 46 sec
Reputation Power: 811
Hi,
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.
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: http://php.net/manual/en/function.mysql-query.php
Posts: 3
Time spent in forums: 25 m 11 sec
Reputation Power: 0
Quote:
Originally Posted by gw1500se
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 for debugging techniques and common problems.
Thanks! now im aware what to read and what to learn.
Posts: 3
Time spent in forums: 25 m 11 sec
Reputation Power: 0
Quote:
Originally Posted by Jacques1
Hi,
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 . 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:
Thanks for the links ill bookmark them, and start learning them.