GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Oct-2005, 13:29
dave_w dave_w is offline
New Member
 
Join Date: Oct 2005
Posts: 8
dave_w is on a distinguished road

Please help me!!!


Can someone please help me. i am tryin to use this login system that i have found on the internet for my website but keep getting this error

Parse error: parse error, unexpected T_STRING in /home/vhosts/dwgame.wagoo2.com/main.php on line 33

The code is as below

PHP Code:

<?
/**
 * Main.php
 *
 * This is an example of the main page of a website. Here
 * users will be able to login. However, like on most sites
 * the login form doesn't just have to be on the main page,
 * but re-appear on subsequent pages, depending on whether
 * the user has logged in or not.
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 26, 2004
 */
include("include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>

<table>
<tr><td>


<?
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b>, you are logged in. <br><br>";
       "[<a href="userinfo.php?user=$session->username">My Account</a>]   ";
       "[<a href="useredit.php">Edit Account</a>]   ";
   if($session->isAdmin()){
      echo "[<a href="admin/admin.php">Admin Center</a>]   ";
   }
   echo "[<a href="process.php">Logout</a>]";
}
else{
?>

<h1>Login</h1>
<?
/**
 * User not logged in, display the login form.
 * If user has already tried to login, but errors were
 * found, display the total number of errors.
 * If errors occurred, they will be displayed.
 */
if($form->num_errors > 0){
   echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me next time     
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
 * Just a little page footer, tells how many registered members
 * there are, how many users currently logged in and viewing site,
 * and how many guests viewing site. Active users are displayed,
 * with link to their user information.
 */
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("include/view_active.php");

?>


</td></tr>
</table>


</body>
</html>

Thankyou to anyone who helps!!!
  #2  
Old 16-Oct-2005, 22:13
dannybedor dannybedor is offline
New Member
 
Join Date: Jul 2005
Posts: 13
dannybedor is on a distinguished road

Re: Please help me!!!


Look at your codes:
PHP Code:

echo "Welcome <b>$session->username</b>, you are logged in. <br><br>";
       "[<a href="userinfo.php?user=$session->username">My Account</a>]   ";
       "[<a href="useredit.php">Edit Account</a>]   "; 



That should be:
PHP Code:

echo "Welcome <b>$session->username</b>, you are logged in. <br><br>";
echo "[<a href="userinfo.php?user=$session->username">My Account</a>]   ";
echo  "[<a href="useredit.php">Edit Account</a>]   "; 



Hope it works.
  #3  
Old 18-Oct-2005, 12:09
dave_w dave_w is offline
New Member
 
Join Date: Oct 2005
Posts: 8
dave_w is on a distinguished road

Re: Please help me!!!


Thanks. that was a great help. got it sorted now!
  #4  
Old 19-Oct-2005, 11:42
dave_w dave_w is offline
New Member
 
Join Date: Oct 2005
Posts: 8
dave_w is on a distinguished road

Re: Please help me!!!


2 more problems that i just need to iron out im my code and they are as follows:

error = Parse error: parse error, unexpected T_STRING, expecting ',' or

';'

PHP Code:

<?php
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b>, you are logged in. 

<br><br>";
   echo "[<a href="userinfo.php?user=$session->username">My 

Account</a>]   ";
   echo "[<a href="useredit.php">Edit Account</a>]   ";
if($session->isAdmin()){ 
      echo "[<a href="admin/admin.php">Admin Center</a>]   ";
   }
   echo "[<a href="process.php">Logout</a>]   ";
}
else{
?>





error = Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,

expecting T_STRING or T_VARIABLE or T_NUM_STRING



PHP Code:

$q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'";
$result = "mysql_query($q, $this->connection)";
if(!$result || (mysql_numrows($result) < 1)){
return 1; //Indicates username failure
}

/* Retrieve userid from result, strip slashes */
$dbarray = "mysql_fetch_array($result)";
$dbarray['userid'] = stripslashes($dbarray['userid']) ;
$userid = "stripslashes($userid)";

/* Validate that userid is correct */
if($userid == $dbarray['userid']){ 



Thanks again to anyone who helps me.... again!
  #5  
Old 19-Oct-2005, 20:21
dannybedor dannybedor is offline
New Member
 
Join Date: Jul 2005
Posts: 13
dannybedor is on a distinguished road

Re: Please help me!!!


You have to be careful when echoing the HTML codes.
Here's part of your first codes:
PHP Code:

echo "[<a href="userinfo.php?user=$session->username">My 

Account</a>]   ";
   echo "[<a href="useredit.php">Edit Account</a>]   ";
if($session->isAdmin()){ 
      echo "[<a href="admin/admin.php">Admin Center</a>]   ";
   }
   echo "[<a href="process.php">Logout</a>]   "; 



Here's that should be written:
PHP Code:

echo '[<a href="userinfo.php?user=$session->username">My 

Account</a>]   ';
   echo '[<a href="useredit.php">Edit Account</a>]   ';
if($session->isAdmin()){ 
      echo '[<a href="admin/admin.php">Admin Center</a>]   ';
   }
   echo '[<a href="process.php">Logout</a>]   '; 



Note that I usually use the aphostrope (') for ECHO so I don't have to worry about HTML quotes (") anymore.

Anyway I should have notice this in my first post.

Your part of your second codes:
PHP Code:

$q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'"; 



If the TBL_USERS is a table name then it should be:
PHP Code:

$q = "SELECT userid FROM TBL_USERS WHERE username = '$username'"; 


or if TBL_USERS is a variable then
PHP Code:

$q = "SELECT userid FROM ".$TBL_USERS." WHERE username = '$username'"; 



Hope this can help you.
__________________
http://www.pojokweb.com
  #6  
Old 20-Oct-2005, 12:49
dave_w dave_w is offline
New Member
 
Join Date: Oct 2005
Posts: 8
dave_w is on a distinguished road

Re: Please help me!!!


1 last problem i need help with. i am gettin the following error

Parse error: parse error, unexpected $

PHP Code:

function query($query){
      return mysql_query($query, $this->connection);
   }
};

/* Create database connection */
  $database = new MySQLDB ;

?> 


......and a HUGE thanks to dannybedor for all of the help that he has given me so far.. THANX!
  #7  
Old 26-Oct-2005, 11:00
djd@n djd@n is offline
New Member
 
Join Date: Oct 2005
Posts: 21
djd@n is on a distinguished road

Re: Please help me!!!


dave where did you find that login script then we coud help you a bit better
 
 

Recent GIDBlogDeveloping GUIs with wxPython (Part 4) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:42.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.