954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Parse Error - Can you spot something?

Hey guys and gals; I've been chipping away at some code today and tried to run my program I am getting the error:
Parse error: syntax error, unexpected '&' in........on line 68

$stmt = $dbh->prepare("SELECT username, password FROM client WHERE username = :username AND password = :password");
<strong>
          &stmt->bindParam(':username', &username, PDO::PARAM_STR);</strong>
          &stmt->bindParam(':password', &password, PDO::PARAM_STR, 40);


The bolded part is line 68. I am pretty new to php and have done a bit of looking into it but only problem is I think my code is right but dont have the knowledge or experience to tell for sure. Any help would be greatly appreciated.

PixelatedKarma
Junior Poster in Training
58 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Do you have a function named username() and a function named password()? Or is it you have variables named $username and $password? At the moment on line 68 and 69 &username = username() function and &password = password() function which I'm guessing do not exist. So try the following:

$stmt = $dbh->prepare("SELECT username, password FROM client WHERE username = :username AND password = :password");
          &stmt->bindParam(':username', $username, PDO::PARAM_STR);
          &stmt->bindParam(':password', $password, PDO::PARAM_STR, 40);
cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

changed the two &stmt to $stmt

$stmt->bindParam(':username', &username, PDO::PARAM_STR);
 $stmt->bindParam(':password', &password, PDO::PARAM_STR, 40);
vaultdweller123
Posting Pro
554 posts since Sep 2009
Reputation Points: 42
Solved Threads: 75
 

Genius - fixing the & for $s made it work - thank you kindly!

Ya the password and username are variable as they are being sent to the database for account creation.

PixelatedKarma
Junior Poster in Training
58 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You