0

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");
[B]
          &stmt->bindParam(':username', &username, PDO::PARAM_STR);[/B]
          &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.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by PixelatedKarma
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);
0

changed the two &stmt to $stmt

$stmt->bindParam(':username', &username, PDO::PARAM_STR);
 $stmt->bindParam(':password', &password, PDO::PARAM_STR, 40);
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.