OneEyedWillie Posted May 27, 2011 Share Posted May 27, 2011 Hi, I am trying to use a tutorial to create a login/register script. I got the register working great and it writes to the db. My problem is with logging in. I get this error: Parse error: syntax error, unexpected T_STRING in C:\ROOT\wamp\www\IsleWar\login.php on line 19 This is line 19: $query = “select * from users where username=’$username’ and password=’$password’”; Full login.php: <?php //Database Information $dbhost = "localhost"; $dbname = "islewar"; $dbuser = "islewar"; $dbpass = "<censored password>"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); session_start(); $username = $_POST[‘username’]; $password = md5($_POST[‘password’]); $query = “select * from users where username=’$username’ and password=’$password’”; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = “Bad Login”; include “login.html”; } else { $_SESSION[‘username’] = “$username”; include “memberspage.php”; } ?> Anything anybody can do to help me would be great! Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
gizmola Posted May 27, 2011 Share Posted May 27, 2011 You have some weird utf-8 characters in there rather than the " and ' that php expects. What editor are you using for your code? Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/#findComment-1221400 Share on other sites More sharing options...
OneEyedWillie Posted May 27, 2011 Author Share Posted May 27, 2011 You have some weird utf-8 characters in there rather than the " and ' that php expects. What editor are you using for your code? I use CoffeeCup Free HTML Editor Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/#findComment-1221401 Share on other sites More sharing options...
gizmola Posted May 27, 2011 Share Posted May 27, 2011 Use a text editor like notepad++ for your php code, or configure CofeeCup to only use ascii for your .php files. Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/#findComment-1221407 Share on other sites More sharing options...
OneEyedWillie Posted May 27, 2011 Author Share Posted May 27, 2011 I used Notepad++ and cPanel and got the same error. In Notepad++ and CoffeeCup I don't see an option for ascii formatting. In cPanel I can choose ascii but when I save, it formats it back to utf-8. Is it possible it is doing that because of me just copying/pasting from the tutorial? If I typed it would it stop the errors? Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/#findComment-1221421 Share on other sites More sharing options...
gizmola Posted May 27, 2011 Share Posted May 27, 2011 Well, rather than fighting this, just find the " and ' characters and replace them with the ones on your keyboard. Yes it is because you cut and pasted from an article that erroneously converted them to different characters. Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/#findComment-1221431 Share on other sites More sharing options...
OneEyedWillie Posted May 27, 2011 Author Share Posted May 27, 2011 Weird, there must be something wrong with either php or MySQL on my friends server. I was trying to use this on his server and was getting that error.. So I tried putting it on my server and it works great now. I'll have to let him know. Thanks for all your help! Quote Link to comment https://forums.phpfreaks.com/topic/237679-syntax-error-unexpected-t_string/#findComment-1221433 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.