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.

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);

changed the two &stmt to $stmt

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.