Kerotan Posted October 12, 2007 Share Posted October 12, 2007 Im new to php/mysql and trying to learn it etc. I tried to do a login script thingy for a website but im having problems when the user trys to log in :S Error: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\login.php on line 19 login.php <?php //Database Information $dbhost = "localhost"; $dbname = "war"; $dbuser = "root"; $dbpass = "****"; //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”; } ?> Anyone know what the problem is and how i fix it? :S Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 13, 2007 Share Posted October 13, 2007 $query = “select * from users where username=’$username’ and password=’$password’”; $query = "select * from users where username='$username' and password='password'"; use "" or ' Quote Link to comment Share on other sites More sharing options...
Kerotan Posted October 13, 2007 Author Share Posted October 13, 2007 $query = “select * from users where username=’$username’ and password=’$password’”; $query = "select * from users where username='$username' and password='password'"; use "" or ' Thanks for the quick response but.. I dont get you Use "" or ' were or instead of what? lol.. Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 13, 2007 Share Posted October 13, 2007 you have to use single or double quote in your case i dont know you use how do i call that im use its not single or double quote Quote Link to comment Share on other sites More sharing options...
Kerotan Posted October 13, 2007 Author Share Posted October 13, 2007 Hrm.. I am using "" or ' in the script if thats what you mean :S Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 13, 2007 Share Posted October 13, 2007 try and tell us the error <?php session_start(); $dbhost = "localhost"; $dbname = "war"; $dbuser = "root"; $dbpass = "****"; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $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'; } ?> Quote Link to comment Share on other sites More sharing options...
Kerotan Posted October 13, 2007 Author Share Posted October 13, 2007 Getting this error now... Parse error: syntax error, unexpected $end in C:\wamp\www\memberspage.php on line 32 Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 13, 2007 Share Posted October 13, 2007 check your includes believe the erroe lies there Quote Link to comment Share on other sites More sharing options...
lemke411 Posted October 16, 2007 Share Posted October 16, 2007 I have a couple tips that you could use to make you coding a little easier. 1st: Create a connect.php file and include it (it just looks nicer and less cluttered and changes happen in one place) 2nd Do a header("location: page.php"); instead of an include 3rd Don't use html or htm extensions because later on you may want to do some php in those pages and then you will have to change them. Quote Link to comment Share on other sites More sharing options...
fenway Posted October 16, 2007 Share Posted October 16, 2007 This is now a php error only -- if the sql part has been resolved, I'll move this thread accordingly. Quote Link to comment 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.