Results 1 to 3 of 3

Thread: Please I need help with this PHP Update code.

Hybrid View

  1. #1
    Join Date
    Jan 2013

    Please I need help with this PHP Update code.

    Hello everyone!

    Please I need help updating my database from a html form.

    I'm quite new to PHP. I can't figure out where the error is.

    Please can anyone help?

    Thank you very much!

    HTML Code:
    mysql_connect("localhost", "root", "");
    $UpdateQuery = "UPDATE articles_selection SET article = '$_POST[article]' WHERE id ='$_POST[hidden]'";
    mysql_query($UpdateQuery, $sql);
    $sql = mysql_query("SELECT * FROM articles_selection");
    echo "<table border = '1'>
    while($record = mysql_fetch_array($sql)){
    echo "<form action="index1.php" method ="post">";
    echo "<tr>";
    echo "<td>" . "<input type = "text" name = "id" value ="  . $record['id'] . " </td>";
    echo "<td>" . "<input type = "text" name = "article" value ="  . $record['article'] . " </td>";
    echo "<td>" . "<input type = "hidden" name = "hidden" value ="  . $record['id'] . " </td>";
    echo "<td>" . "<input type = "submit" name = "Update" value = "update">" . " </td>";
    echo "</tr>";
    echo "</form>";
    echo "</table>";

  2. #2
    Join Date
    Aug 2004
    double quotes within a double-quoted string literal need to be escaped, or else use single quotes:
    PHP Code:
    // syntax error:
    echo "<form action="index1.php" method ="post">";

    // instead escape the literal quotes within the string:
    echo "<form action=\"index1.php\" method =\"post\">";

    // or else you could use single quotes within the HTML markup:
    echo "<form action='index1.php' method ='post'>"
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Jan 2013
    Thank you very much!! I used single quotes within the HTML markup, and it worked.

    Thank you!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center