By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

login authendication

P: 3
*************error********************************


( ! ) Parse error: syntax error, unexpected T_STRING in C:\wamp\www\login.php on line 19

**********************end of error*****************

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <?php
  4.  
  5. //Database Information
  6.  
  7. $dbhost = "localhost";
  8. $dbname = "test";
  9. $dbuser = "username";
  10. $dbpass = "";
  11.  
  12. //Connect to database
  13.  
  14. mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
  15. mysql_select_db($dbname) or die(mysql_error());
  16.  
  17. session_start();
  18. $username = $_POST[‘username’];
  19. $password = md5($_POST[‘password’]);
  20.  
  21. $query = “select * from users1 where username='mysql_real_escape_string($POST['username']).' and password='mysql_real_escape_string($POST['password']).' ”;
  22.  
  23. $result = mysql_query($query);
  24.  
  25. if (mysql_num_rows($result) != 1) {
  26. $error = “Bad Login”;
  27.     include “login.html”;
  28.  
  29. } else {
  30.     $_SESSION[‘username’] = “$username”;
  31.     include “memberspage.php”;
  32. }
  33.  
  34. ?>
  35.  
  36.  
  37.  
Mar 8 '12 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,035
The error is obviously on line 19 of your PHP-script.
Because you posted two empty lines extra,
It is on line 21 of the code you posted.

I think you are messing up too much with single- and double-quote when trying to use the function 'mysl_real_escape_string()' in our code.

Expand|Select|Wrap|Line Numbers
  1. $username = mysql_real_escape_string($_POST[‘username’]);
  2.  19. $password = mysql_real_escape_string(md5($_POST[‘password’]));
  3.  20. 
  4.  21. $query = “select * from users1 where username=$username and password=$password ”;
  5.  
Mar 24 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.