www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] MySQL syntax error

  1. #1
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157

    resolved [RESOLVED] MySQL syntax error

    Hello all,

    I am writing a log-in script for a webpage and I cant seem to see my error anymore, I have no clue where to find it.

    Here is the error:
    Code:
    [10-Aug-2014 10:01:52 America/Denver] array (
      0 => '42000',
      1 => 1064,
      2 => 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'
    								Password = \'148870a26b36b6441cbc9fe84f5ad1f8671df2bd\'\' at line 9',
    )
    And here is the PHP code that goes along with it:
    Code:
    try {
    							$LGC = new PDO('mysql:host=localhost; dbname=***', '*****', '****');
    							$LGC->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    								//Prepares the SQL Statement
    								$SLU = $LGC->prepare(
    								"SELECT
    								Username,
    								Password,
    								Active,
    								UID
    								FROM
    								Users
    								WHERE
    								Username = :Uname,
    								Password = :DbPass
    								");
    									//Binds the variables 
    									$SLU->bindParam(':Uname', $User);
    									$SLU->bindParam(':DbPass', $ENC);
    									
    										//Executes the SQL Statement matching the information given
    										$SLU->execute();
    										
    											//Sets the results 
    											$result = $SLU->fetch(PDO::FETCH_ASSOC);
    												$Uname = $result['Username'];
    												$Active = $result['Active'];
    												$UID = $result['UID'];
    							}
    							catch (PDOException $ex) {
    							$msg = $ex->errorInfo;
    							error_log(var_export($msg, true));
    							die("<h1 style='color:red'>Error LG_01, Please contact the administrator!</h1>");
    							}
    Any help would be great

  2. #2
    Join Date
    May 2014
    Posts
    77
    At a quick 3:30am glance:
    Code:
    SELECT Username, Password, Active, UID FROM Users WHERE Username = :Uname, Password = :DbPass;
    
    SELECT Username, Password, Active, UID FROM Users WHERE Username = :Uname AND Password = :DbPass;
    Last edited by NogDog; 08-10-2014 at 05:19 PM.

  3. #3
    Join Date
    Jun 2009
    Location
    Chi town. IL68 ICAO code home airport, literally.
    Posts
    157
    Thanks!

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



Recent Articles