Im having problems updating a mysql database with php using a form

PHP , MYSQL , APACHE Leicester, United Kingdom
  • 11 years ago

    Hi,

    I'm hoping someone may be able to help me with a slight problem i'm having with trying to retrieve and update/edit my values from a MySQL database which are used in an updateable form that allow edits, and send back the edited text into a MySQL database. I've been able to successfully retrieve the text and put it into the editable form, but when I submit the text it doesn't change in the database. could you please tell me where im going wrong, thanks. heres my code;

  • 11 years ago
  • 11 years ago
  • 11 years ago
    <?php
    

    // Database Connection $dbcnx = @mysqlconnect('localhost', 'root', 'password); if (!$dbcnx) { exit('

    Unable to connect to database server.

    '); } if (!@mysqlselect_db('ecommerce')) { exit('

    Unable to locate ecommerce database.'); }

    echo '

    Edit if (isset($POST['productsid'])) $productspart = $POST['productspart']; $productsname = $POST['productsname']; $productsproddesc = $POST['productsproddesc']; $productsspec = $POST['productsspec']; $productsprice = $POST['products_price']; $sql5 = "UPDATE products SET productspart='$productspart', productsname='$productsname' WHERE productsid='$productsid'"; if (@mysqlquery($sql5)) { echo 'Product details updated.'; } else { echo 'Error updating: ' . mysql

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra