Community discussion forum

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

  • 4 months 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;

    Post was edited on 06/07/2009 13:04:32 Report abuse
  • 4 months ago
  • 4 months ago
  • 4 months 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).

Want to stay in touch with what's going on? Follow us on twitter!