#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Smile 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

    <input name="name" type="text" id="name" value="<? echo $rows['name']; ?>">

    Im willing to cooperate thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,466
    Rep Power
    594
    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.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    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:
    http://tut.php-quake.net/en/index.html

    Specifically for databases, there's also this wiki:
    http://wiki.hashphp.org/PDO_Tutorial...SQL_Developers

    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
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    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.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    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.

    Comments on this post

    • Jacques1 agrees : Great attitude!
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Originally Posted by raijinlee
    Thanks for the links ill bookmark them, and start learning them.
    Great.

    Comments on this post

    • gw1500se agrees : Because there are so many bad tutorials out there, perhaps you might be willing to create another sticky pointing that out and referencing good tutorials.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo