Results 1 to 2 of 2

Thread: SQL syntax error corresponds to MariaDB Server version.

  1. #1
    Join Date
    Jun 2017
    Location
    Bengaluru, Karnataka, India
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Post SQL syntax error corresponds to MariaDB Server version.

    I am getting an error which says "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 '(Username,Email,EmployeeID,Designation,Password, WHERE Id = '7'' at line 1".

    I tried with some solutions, but I didn't fixed it. Please give solution for this and also explain something about this. My code is:

    PHP Code:
    <?php
        session_start
    ();
        
    $id=$_SESSION['Id'];
        if(isset(
    $_POST)){
            require 
    '../_database/database.php';
            
    $username $_REQUEST['Username'];
            
    $email $_REQUEST['Email'];
            
    $employee $_REQUEST['EmployeeID'];
            
    $designation $_REQUEST['Designation'];
            
    $password $_REQUEST['Password'];
            
    $query "UPDATE users SET (Username,Email,EmployeeID,Designation,Password, WHERE Id = '$id'";
            
    $stmt mysqli_prepare($database,$query)or die(mysqli_error($database));
            
    $stmt->bind_param('sssss'$username$email$employee$designation$password);
            
    $stmt->execute();
            
    //header("location:../user.php?Username=$temp&request=profile-update&status=success");
        
    }    
    ?>
    Last edited by keyboard; 06-22-2017 at 10:00 AM. Reason: Format: PHP tags

  2. #2
    Join Date
    Jan 2015
    Posts
    78
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default

    @ak47, while it appears you may have seen my reply in your previous thread and are trying to do a couple of the things mentioned, it also appears that you are just randomly making changes to your code for no reason.

    Your previous code was using a working way of testing if the form has been submitted. The current code is not. $_POST is always set, even if it is empty, and the code using isset() will always be true.

    You should also not use $_REQUEST, use the $_POST variables that match the form's method, and as mentioned in the other thread, there's no good reason to copy a bunch of variables to other variables. Just use the $_POST variables in the ->bind_param() call.

    The reason for the sql syntax error you are getting is because what you have now isn't the correct syntax for an UPDATE statement. The syntax you had in the previous thread was correct. Converting the sql statement to a prepared query would have only involved replacing the php variables with ? place-holders, and removing the single-quotes around each value.

  3. The Following User Says Thank You to DyDr For This Useful Post:

    ak47 (06-22-2017)

Similar Threads

  1. Replies: 1
    Last Post: 01-28-2011, 03:39 AM
  2. Replies: 2
    Last Post: 02-25-2010, 07:35 AM
  3. Replies: 2
    Last Post: 02-12-2010, 09:53 AM
  4. Replies: 1
    Last Post: 04-26-2008, 11:22 AM
  5. Replies: 3
    Last Post: 01-08-2008, 12:49 PM

Bookmarks

Posting Permissions

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