Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Please can some one help me with this problem

Please can some one help me with this problem

Scheduled Pinned Locked Moved Web Development
helpdatabasemysqlannouncementsysadmin
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14800891
    wrote on last edited by
    #1

    I have this CMS work, at the edit_subject page, I have some problem that say ( The subject update failed. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '} WHERE id = 1' at line 4) This is the page 30); foreach($fields_with_lengths as $fieldname => $maxlength ){ if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; } } if (empty($errors)) { // Perform Update $id = mysql_prep($_GET['subj']); $menu_name = mysql_prep($_POST['menu_name']); $position = mysql_prep($_POST['position']); $visible = mysql_prep($_POST['visible']); $query = "UPDATE subjects SET menu_name = '{$menu_name}', position = {$position}, visible = {visible} WHERE id = {$id}"; $result = mysql_query($query, $connection); if (mysql_affected_rows() == 1) { // Success $message = "The subject was successfully updated."; } else { // Failed $message = "The subject update failed. "; $message .= "
    ". mysql_error(); } } else{ // Errors occurred $message = "There were " . count($errors) . " errors in the form. "; } }// end: if (isset($_POST['submit'])) ?>

    Edit Subject:

    " . $message . "

    ";} ?> "; echo "Please review the following fields;
    "; foreach($errors as $errors) { echo " - " . $errors . "
    "; } echo "

    "; } ?>

    Subject name:

    G Richard DeemingR 2 Replies Last reply
    0
    • M Member_14800891

      I have this CMS work, at the edit_subject page, I have some problem that say ( The subject update failed. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '} WHERE id = 1' at line 4) This is the page 30); foreach($fields_with_lengths as $fieldname => $maxlength ){ if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; } } if (empty($errors)) { // Perform Update $id = mysql_prep($_GET['subj']); $menu_name = mysql_prep($_POST['menu_name']); $position = mysql_prep($_POST['position']); $visible = mysql_prep($_POST['visible']); $query = "UPDATE subjects SET menu_name = '{$menu_name}', position = {$position}, visible = {visible} WHERE id = {$id}"; $result = mysql_query($query, $connection); if (mysql_affected_rows() == 1) { // Success $message = "The subject was successfully updated."; } else { // Failed $message = "The subject update failed. "; $message .= "
      ". mysql_error(); } } else{ // Errors occurred $message = "There were " . count($errors) . " errors in the form. "; } }// end: if (isset($_POST['submit'])) ?>

      Edit Subject:

      " . $message . "

      ";} ?> "; echo "Please review the following fields;
      "; foreach($errors as $errors) { echo " - " . $errors . "
      "; } echo "

      "; } ?>

      Subject name:

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      Your post is quite poorly formatted, but it looks like you are missing a $ symbol where {visible} should be {$visible}.

      1 Reply Last reply
      0
      • M Member_14800891

        I have this CMS work, at the edit_subject page, I have some problem that say ( The subject update failed. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '} WHERE id = 1' at line 4) This is the page 30); foreach($fields_with_lengths as $fieldname => $maxlength ){ if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; } } if (empty($errors)) { // Perform Update $id = mysql_prep($_GET['subj']); $menu_name = mysql_prep($_POST['menu_name']); $position = mysql_prep($_POST['position']); $visible = mysql_prep($_POST['visible']); $query = "UPDATE subjects SET menu_name = '{$menu_name}', position = {$position}, visible = {visible} WHERE id = {$id}"; $result = mysql_query($query, $connection); if (mysql_affected_rows() == 1) { // Success $message = "The subject was successfully updated."; } else { // Failed $message = "The subject update failed. "; $message .= "
        ". mysql_error(); } } else{ // Errors occurred $message = "There were " . count($errors) . " errors in the form. "; } }// end: if (isset($_POST['submit'])) ?>

        Edit Subject:

        " . $message . "

        ";} ?> "; echo "Please review the following fields;
        "; foreach($errors as $errors) { echo " - " . $errors . "
        "; } echo "

        "; } ?>

        Subject name:

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query. PHP: SQL Injection - Manual[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups