tecmeister Posted February 6, 2008 Share Posted February 6, 2008 Im creating a register page. When i click on submit this is the error that im getting. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/sites/nurevolution.co.uk/public_html/register.php on line 29 This is the script that i have used; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php //Database Information $dbhost = "localhost"; $dbname = "your database name"; $dbuser = "username"; $dbpass = "yourpass"; //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 1 username=’$username’ and password=’$password’; line 29 $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = “Bad Login”; include “login.html”; } else { $_SESSION[‘username’] = “$username”; include “memberspage.php”; } ?> </body> </html> Thanks for the help that you may be able to give me. tecmeister Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/ Share on other sites More sharing options...
haku Posted February 6, 2008 Share Posted February 6, 2008 Put double quotes before select, and after 'password' Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459396 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 Put double quotes before select, and after 'password' Thanks alot that worked. There is a another error. line 34 $error = “Bad Login”; Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459400 Share on other sites More sharing options...
mmarif4u Posted February 6, 2008 Share Posted February 6, 2008 What that error is. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459401 Share on other sites More sharing options...
haku Posted February 6, 2008 Share Posted February 6, 2008 What's the error? Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459403 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 What's the error? It is ok i have sorted that out now In just having problems connection the mysql I have changed the script to: mysql_connect ("localhost","myusername","mypassword")or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); what could the problem be? Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459413 Share on other sites More sharing options...
revraz Posted February 6, 2008 Share Posted February 6, 2008 Without you telling us the error, we can't help you. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459421 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 Without you telling us the error, we can't help you. O yeah very sorry. This is the error that im getting: Access denied for user 'web88-tecmeister'@'%' to database 'your database name' Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459423 Share on other sites More sharing options...
haku Posted February 6, 2008 Share Posted February 6, 2008 Looks like either your username or your password is incorrect. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459428 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 Looks like either your username or your password is incorrect. I thought that but i have checked it over a few times. I have put everything back to the default im now getting a error on: Parse error: syntax error, unexpected T_VARIABLE in /home/sites/nurevolution.co.uk/public_html/register.php on line 31 $result = mysql_query($query); Im sorry for all of the questions. That is how much of a newbie i am. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459433 Share on other sites More sharing options...
frijole Posted February 6, 2008 Share Posted February 6, 2008 do you need quotes around your query? Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459436 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 do you need quotes around your query? Im sorry i dont really know. This is my first time doing this. This is the website that im getting the script form: http://www.swish-db.com/tutorials/view.php/tid/601 Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459437 Share on other sites More sharing options...
frijole Posted February 6, 2008 Share Posted February 6, 2008 on the site the query is structured like this: $query = "INSERT INTO users (name, email, username, password) VALUES('$name', '$email', '$username', '$password')"; your query is missing these, try changing $query from $query = your query; to $query = "your query" Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459440 Share on other sites More sharing options...
haku Posted February 6, 2008 Share Posted February 6, 2008 The error is rarely on the line it says its on. Its almost always on an earlier line. Post the few lines before the error. You probably forgot a semi-colon on a previous line. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459441 Share on other sites More sharing options...
frijole Posted February 6, 2008 Share Posted February 6, 2008 don't forget the semi-colon like i just did Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459442 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 don't forget the semi-colon like i just did Yeah thanks done that one now. Now to the other error that i had previously. $error = “Bad Login”; Parse error: syntax error, unexpected T_STRING in /home/sites/nurevolution.co.uk/public_html/register.php on line 34 Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459448 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 don't forget the semi-colon like i just did Thanks that worked. Now we can sort out the previous error. Parse error: syntax error, unexpected T_STRING in /home/sites/nurevolution.co.uk/public_html/register.php on line 34 $error = “Bad Login”; Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459455 Share on other sites More sharing options...
Stooney Posted February 6, 2008 Share Posted February 6, 2008 Repost your script with all the changes you've made please. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459457 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 Repost your script with all the changes you've made please. Here is the script: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php //Database Information $dbhost = "localhost"; $dbname = "your database name"; $dbuser = "username"; $dbpass = "yourpass"; //Connect to database mysql_connect ( 'localhost','web88-tecmeister','penalcoir')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 1 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”; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459460 Share on other sites More sharing options...
Stooney Posted February 6, 2008 Share Posted February 6, 2008 First off, please put code in the code tags. Change $query = "select * FROM 'users' WHERE 1 username=’$username’ and password=’$password’"; to $query = "select * FROM users WHERE 1 username='$username' and password='$password'"; Backdrops (`) should only go around column names. Enclose variables in single quotes. Backdrops aren't required in this case. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459467 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 ok thanks. This is the next error. Parse error: syntax error, unexpected T_STRING in /home/sites/nurevolution.co.uk/public_html/register.php on line 34 $error = “Bad Login”; Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459468 Share on other sites More sharing options...
Stooney Posted February 6, 2008 Share Posted February 6, 2008 This should do it. Include needs parenthesis (ex include("file.php"); ) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php //Database Information $dbhost = "localhost"; $dbname = "your database name"; $dbuser = "username"; $dbpass = "yourpass"; //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 1 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”); } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459478 Share on other sites More sharing options...
tecmeister Posted February 6, 2008 Author Share Posted February 6, 2008 That part is done now. Thanks for every ones help. The reason why i was having the problems was: I copied and paste the data and some of the symbols didn't work. But yeah thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/89662-solved-parse-error-syntax-error-unexpected-t_constant_encapsed_string/#findComment-459483 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.