demonlord 0 Report post Posted June 4, 2008 Ok so i'm working on a site for my chruch, and i seem to be having a little bit of trouble with the user.php file i keep getting the following error: Parse error: syntax error, unexpected T_STRING in /home/darkzone/public_html/test/user.php on line 195and i was wondering if some one could help me with the script. //Define a few variables $x = $_GET['x']; $u = $_GET['u'];class register { function displayform($title) { echo('<fieldset><legend>'.$title.'</legend> <form method="POST" name="register"> Username linenums:0'><?PHP session_start(); ob_start(); //Include the configurations include('config.php'); //Define a few variables $x = $_GET['x']; $u = $_GET['u'];class register { function displayform($title) { echo('<fieldset><legend>'.$title.'</legend> <form method="POST" name="register"> Username:<br /> <input type="text" name="username">*<br /><br /> Password:<br /> <input type="password" name="password1">*<br /><br /> Confirm Password:<br /> <input type="password" name="password2">*<br /><br /> Email:<br /> <input type="text" name="email">*<br /><br /> Real Name:<br /> <input type="text" name="realname">*<br /><br /> Website:<br /> <input type="text" name="website"><br /><br /> Location:<br /> <input type="text" name="location"><br /><br /> <input type="submit" name="register" value="Register!"> </form> </fieldset>'); } function process($username, $password1, $password2, $email, $realname, $website, $location) { //Lets define the Queries for searching $SearchUN = mysql_query(" SELECT * FROM `users` WHERE `username` = '$username'"); if(!$SearchUN) die(mysql_error()); $SearchEM = mysql_query(" SELECT * FROM `users` WHERE `email` = '$email'"); if(!$SearchEM) die(mysql_error()); $s1 = mysql_fetch_array($SearchUN); $s2 = mysql_fetch_array($SearchEM); //Did they leave any vital fields empty? if(!$username || !$password1 || !$password2 || !$email || !$realname) { echo('Please fill in all required fields!'); } elseif($password1 !== $password2) { echo('The supplied passwords do not match.'); } elseif($s1[id]) { echo('That user already exists.'); } elseif($s2[id]) { echo('That email is already in use.'); } else { $InsertQRY = mysql_query(" INSERT INTO `users` ( `username`, `password`, `email`, `realname`, `website`, `location` ) VALUES ( '$username', 'md5($password2)', '$email', '$realname', '$website', '$location' )"); if(!$InsertQRY) die(mysql_error()); echo('You have successfully registered!'); } } }class profile { function edit_display($title) { //Define the Search query, to fetch information $SearchQRY = mysql_query(" SELECT * FROM `users` WHERE `username` = '$_SESSION[username]' "); if(!$SearchQRY) die(mysql_error()); $user = mysql_fetch_array($SearchQRY); echo('<fieldset><legend>'.$title.'</legend> <form method="POST" name="edit"> Email:<br /> <input type="text" name="email" value="'.$user.'"><br /><br /> Real Name:<br /> <input type="text" name="realname" value="'.$user[realname].'"><br /><br /> Website:<br /> <input type="text" name="website" value="'.$user[website].'"><br /><br /> Location:<br /> <input type="text" name="location" value="'.$user[location].'"><br /><br /> <input type="submit" name="edit" value="Edit Profile!"> </form> </fieldset>'); } function edit_process($email, $realname, $website, $location) { //Define search query, again, used to replace info if its empty $SearchQRY = mysql_query(" SELECT * FROM `users` WHERE `username` = '$_SESSION[username]' "); if(!$SearchQRY) die(mysql_error()); $user = mysql_fetch_array($SearchQRY); if(!$email) { $email = $user; } if(!$realname) { $realname = $user[realname]; } //Update the information $UpdateQRY = mysql_query(" UPDATE `users` SET `email` = '$email', `realname` = '$realname', `website` = '$website', `location` = '$location' "); if(!$UpdateQRY) die(mysql_error()); echo('You have successfully updated your profile!'); } function view($id) { //Define Query for searching for user info $SearchQRY = mysql_query(" SELECT * FROM `users` WHERE `id` = '$id' "); if(!$SearchQRY) die(mysql_error()); $user = mysql_fetch_array($SearchQRY); if(mysql_num_rows($SearchQRY) == 0) { echo('Invalid Member ID.'); } else { echo('<fieldset><legend>'.$user[username].''s Profile</legend> Username: '.$user[username].'<br /> Email: '.$user.'<br /> Real Name: '.$user[realname].'<br /> Website: '.$user[website].'<br /> Location: '.$user[location].' </fieldset>'); } } }class log { function login_process($username, $password) { //Find the information $FindInfo = mysql_query(" SELECT * FROM `users` WHERE `username` = '$username' AND `password` = 'md5($password)' "); if(!$FindInfo) die(mysql_error()); $F = mysql_fetch_array($FindInfo); if(!$F[id]) { echo('Sorry, those credentials are incorrect.'); } else { $_SESSION['username'] = $username; $_SESSION['password'] = md5($password); $_SESSION['id'] = $F[id]; echo('You have been successfully logged in!'); } } function login_display($title) { echo('<fieldset><legend>'.$title.'</legend> <form method="POST" name="login"> Username:<br /> <input type="text" name="username"><br /><br /> Password:<br /> <input type="password" name="password"><br /><br /> <input type="submit" name="login" value="Login!"> </form> </fieldset>'); } function logout() { header('Location: index.php'); $_SESSION['username'] = ""; $_SESSION['password'] = ""; } }$register = new register; $log = new log; $profile = new profile; if(!$_SESSION['username']) { echo('<a href="?x=register">Register</a> | <a href="?x=login">Login</a><br /><br />'); } else { echo('<a href="?x=editprofile">Edit Profile</a> | <a href="?x=viewprofile&u='.$_SESSION['id'].'">View Profile</a><br /><br />'); } if(!$x) { echo('Welcome to the users system!'); } elseif($x == "register") { if($_SESSION['username']) { echo('You cannot register while logged in!'); } else { if($_POST['register']) { $register->process($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['email'], $_POST['realname'], $_POST['website'], $_POST['location']); } else { $register->displayform("Register An Account"); } } } elseif($x == "login") { if($_SESSION['username']) { echo('You are alreadfy logged in!'); } else { if($_POST['login']) { $log->login_process($_POST['username'], $_POST['password']); } else { $log->login_display("Login To Your Account"); } } } elseif($x == "logout") { if(!$_SESSION['username']) { echo('You are alreadfy logged out!'); } else { $log->logout(); } } elseif($x == "editprofile") { if(!$_SESSION['username']) { echo('You must be logged in to edit your profile!'); } else { if($_POST['edit']) { $profile->edit_process($_POST['email'], $_POST['realname'], $_POST['website'], $_POST['location']); } else { $profile->edit_display("Edit Your Profile"); } } } elseif($x == "viewprofile") { $profile->view($u); } ?> Share this post Link to post Share on other sites
chappill 0 Report post Posted June 4, 2008 Well I'm not too good at php but I've seen this problem loads. T_string refers to the $ whatever thing (see I don't know what even thats called). $user = mysql_fetch_array($SearchQRY);I believe that is your problem but unless you tell us where line 195 is we can't do much, without tediously checking the whole script :/. Hope thats helped a little if not then ahh well lol. Share this post Link to post Share on other sites
truefusion 3 Report post Posted June 4, 2008 Line 195 would be: echo('<fieldset><legend>'.$user[username].''s Profile</legend>You forgot to escape the single quote before the letter S. It should be: echo('<fieldset><legend>'.$user[username].'\'s Profile</legend> Share this post Link to post Share on other sites
Live-Dimension 0 Report post Posted June 4, 2008 Here's the problem - sorry for lack of "technical" words but they've escaped me for the moment. First - you don't need brackets around echo functions.  This does the same thing, and the first method is most preferred too as it's easier to read. echo "text"; echo ("text");  So, to what's producing the error. echo('<fieldset><legend>'.$user[username].''s Profile</legend> What you've tried to do is put in a ' but in your current setting that ends the string. There's two ways to do this. One - put in a slash \ right before the second '. The \ makes the second ' as escaped. What this means is that php sees it as text, and not part of the syntax. The other is to use 'rabbit ears' aka ". Compare these. echo('<fieldset><legend>'.$user[username].'\'s Profile</legend>Username: '.$user[username].'<br />Email: '.$user[email].'<br />Real Name: '.$user[realname].'<br />Website: '.$user[website].'<br />Location: '.$user[location].'</fieldset>');echo "<fieldset><legend>{$user[username]}'s Profile</legend>Username: {$user[username]}<br />Email: {$user[email]}<br />Real Name: {$user[realname]}<br />Website: {$user[website]}<br />Location: {$user[location]}</fieldset>";Yes, there's significant difference between ' and ". Either can be used to start a string and end a string. The ending one has to be the same as the starting one. " is more special then your standard text - and here's why. Minus the last two, all of these are valid and will echo This is test text. $string = "test";echo "This is $string test"; //Check Noteecho 'This is '.$string.' test';echo "This is {$string} test";echo 'This is $string test"; // outputs This is $string testecho 'This is {$string} test"; // outputs This is {$string} test Note This method can only be used with simple variables. They cannot be used with arrays where you can select the position. This is what the {} are for. For Example. echo "This is {'te'.'st'} text";Note the addition taking place? You can do almost anything inside that bracket. To sum up - You can use "" and ''. You can use them inside each other without problems. "t'es't" (outputs t'es't). You can't do this - 't'es't' (outputs error). However, you can escape them to do this. 't\'es\'t' (outputs t'es't). Well I'm not too good at php but I've seen this problem loads. T_string refers to the $ whatever thing (see I don't know what even thats called).That $ tells php that the string after it is in fact a variable. test //string $test //varible Share this post Link to post Share on other sites
demonlord 0 Report post Posted June 5, 2008 Line 195 would be: echo('<fieldset><legend>'.$user[username].''s Profile</legend>You forgot to escape the single quote before the letter S. It should be: echo('<fieldset><legend>'.$user[username].'\'s Profile</legend> thanks that fixed it. Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted June 5, 2008 Topic is resolved.Please PM any moderator to continue this discussion. Until then, this topic is closed. Share this post Link to post Share on other sites