avatar.alex Posted November 27, 2007 Share Posted November 27, 2007 Ok I pretty much have this system done I just need some help with this part. It all works except for when I login. The registration work fine!!! The problem is on line 20 Parse error: parse error, unexpected T_STRING in /home/www/avatar-alex.freehostia.com/login.php on line 20 <?php //Database Information $dbhost = "mysql2.freehostia.com"; $dbname = "alealb52_login"; $dbuser = "alealb52_login"; $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”; } ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 <?php session_start(); //Database Information $dbhost = "mysql2.freehostia.com"; $dbname = "alealb52_login"; $dbuser = "alealb52_login"; $dbpass = "siko65"; //Connect to database 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"; } ?> try.. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 27, 2007 Share Posted November 27, 2007 session_start(); Should be the first line of code after <?php Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 session_start(); Should be the first line of code after <?php i did and thats not the errors trying to say! Quote Link to comment Share on other sites More sharing options...
avatar.alex Posted November 27, 2007 Author Share Posted November 27, 2007 The Login.php file works fine thanks so much!!!! Ok thanks now a new problem...i though everything works it turns out the members page has an error I DON'T KNOW HOW!!! But it does: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, support@freehostia.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. -------------------------------------------------------------------------------- Apache/1.3.33 Server at avatar-alex.freehostia.com Port 80 <? // members page session_start(); //Database Information $dbhost = "mysql2.freehostia.com"; $dbname = "alealb52_login"; $dbuser = "alealb52_login"; $dbpass = "****"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $query="SELECT * FROM users "; $result=mysql_query($query); $num = mysql_num_rows ($result); if ($num > 0 ) { $i=0; while ($i < $num) { $username = mysql_result($result,$i,"category"); if (!$username) { print "Please login below!"; include 'login.html'; } else if ($username == "admin") { echo "I can edit members here, right!<br >"; } else { print"<html>"; print"<head>"; print"<title>MEMBERS ONLY</title>"; print"</head>"; print"<body>"; print"Your Members Page...."; print"</body>"; print"</html>"; } } } ?> P.S. Sorry about all the troble I am still learning how to use PHP an MySQL sorry Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 you have a sql error $query="SELECT * FROM login "; $result=mysql_query($query) or die (mysql_error()); $num = mysql_num_rows ($result); try to add a sql error to know what causes this prob.. Quote Link to comment Share on other sites More sharing options...
avatar.alex Posted November 27, 2007 Author Share Posted November 27, 2007 you have a sql error $query="SELECT * FROM login "; $result=mysql_query($query) or die (mysql_error()); $num = mysql_num_rows ($result); try to add a sql error to know what causes this prob.. I found wat i did. I didn't make a login table i changed it to users. I changed the error Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 is this solved? mark it solved if it is ! Quote Link to comment Share on other sites More sharing options...
avatar.alex Posted November 28, 2007 Author Share Posted November 28, 2007 no lol im still lookin up stuff and tryin to fix it!!! Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 tip top tips.. never ever nest your questions if the first problem is solve than mark that solve and try to start a new thread if you it needs huge explanations .. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 28, 2007 Share Posted November 28, 2007 I wasn't posting to you. What good does giving him new code without explaining to him what you did? He won't learn if you don't show him how to fix it. session_start(); Should be the first line of code after <?php i did and thats not the errors trying to say! Quote Link to comment Share on other sites More sharing options...
avatar.alex Posted November 28, 2007 Author Share Posted November 28, 2007 I wasn't posting to you. What good does giving him new code without explaining to him what you did? He won't learn if you don't show him how to fix it. session_start(); Should be the first line of code after <?php i did and thats not the errors trying to say! Having it explained to me helps me I can also learn by going through the code!!! Thanks! Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 @revraz i hate teaching everything like teaching a kidz STOP LOOK AND LISTEN.. if you want ot become a programmer and you cant figure out this simple thing i mean figuring out what and why your system is fixed then you must turn your career as a designer not a programmer.. i hate explaining everything y? when ever i gave an edited code in expecting that he os she will give it a try to figure it out all by him/her self sometimes it feels great when you your self know something about something..learning like being spoon feed well turn you as a week developer FOR me programming is one of the hardest task if you look at it carefully.. I love hearing this words "AHh thats it i made it " and not "yes thank you " he might know something but where is the effort i help for free so if you want spoon feeding you have to pay me lol... BOW ! 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.