942,782 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 456
  • PHP RSS
Jun 25th, 2010
0

Parse Error - Can you spot something?

Expand Post »
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");

          &stmt->bindParam(':username', &username, PDO::PARAM_STR);
          &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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
PixelatedKarma is offline Offline
57 posts
since Apr 2010
Jun 25th, 2010
0
Re: Parse Error - Can you spot something?
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:
PHP Syntax (Toggle Plain Text)
  1. $stmt = $dbh->prepare("SELECT username, password FROM client WHERE username = :username AND password = :password");
  2. &stmt->bindParam(':username', $username, PDO::PARAM_STR);
  3. &stmt->bindParam(':password', $password, PDO::PARAM_STR, 40);
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,003 posts
since Sep 2007
Jun 26th, 2010
0
Re: Parse Error - Can you spot something?
changed the two &stmt to $stmt

PHP Syntax (Toggle Plain Text)
  1. $stmt->bindParam(':username', &username, PDO::PARAM_STR);
  2. $stmt->bindParam(':password', &password, PDO::PARAM_STR, 40);
Reputation Points: 32
Solved Threads: 57
Posting Pro in Training
vaultdweller123 is offline Offline
465 posts
since Sep 2009
Jun 26th, 2010
0
Re: Parse Error - Can you spot something?
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
PixelatedKarma is offline Offline
57 posts
since Apr 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: SESSION
Next Thread in PHP Forum Timeline: help with ns servers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC