strange error
i have come accross an strange error ..I m new to php world. i have written the code as in auth_user of PHP4 and it is giving error in 115 line and toal no of lines in the code is 112 and the error shown is
Parse error: parse error, unexpected $ in /var/www/html/alok/auth_user1.php on line 115 and the code is
<html>
<head></head>
<body>
<?php
error_reporting(0);
# FILE: common_db.inc
$dbhost = "192.168.1.25";
$dbusername = "alok";
$dbuserpassword = "alok";
$default_dbname = "store";
$MYSQL_ERRNO = "";
$MYSQL_ERROR = "";
function db_connect($dbname='') {
global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
global $MYSQL_ERRNO, $MYSQL_ERROR;
$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpassword);
if (!$link_id) {
$MYSQL_ERRNO = 0;
$MYSQL_ERROR = "Connection failed to the host $dbhost.";
return 0;
}
else if (empty($dbname) && !mysql_select_db($default_dbname)) {
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
return 0;
}
else if (!empty($dbname) && !mysql_select_db($dbname))
{
$MYSQL_ERRNO=mysql_errno();
$MYSQL_ERROR=mysql_error();
}
else return $link_id;
}
//include "./common_db.inc";
$register_script="./register.php";
function auth_user($username,$password)
{
$link_id=db_connect("store");
$query="select username from login_user where username='$username'and password=password('$password')";
$result=mysql_query($query);
if(!mysql_query($query))
return 0;
else{
$query_data=mysql_fetch_row($result);
return $query_data[0];
}
}
function login_form(){
global $PHP_SELF;
?>
<html>
<head>
<title>LOGIN</title>
</head>
<body>
<form method="POST" action="<?echo$PHP_SELF;?>">
<div align "center"><center>
<h3>please login to access the page u requested.</h3>
<table border="1" width="200" cellpaddin="2">
<tr>
<th width ="18%" align="right" nowrap>id</th>
<td width="82%" nowrap>
<input type ="text" name="username" size="8">
</td>
</tr>
<tr>
<th width="18%" align="right" nowrap>password</th>
<td width="82%" nowrap>
<input type="password" name="password" size="8">
</td>
</tr>
<tr>
<td width="100%" colspan="2" align="center" nowrap>
<input type="submit" value="login" name="submit">
</td>
</tr>
</table>
</center></div>
</form></body></html>
<?
}
session_start();
error_reporting(0);
if(!isset($username) | !($password))
{
login_form();
exit;
}
else{
session_register("username","password");
$username=auth_user($username,$password);
if(!username)
{
session_unregister($username);
session_unregister($password);
echo "Authentication failed".
"you must enter a valid username and password.".
"retry the entry<br>\n";
echo"<A HREF=\"$PHP_SELF\">Login</A><br>";
echo " If u are not a member yet,click ".
"on the following link to register.<br>\n";
echo "<a href =\"$register_script\">Membership</a>";
exit;
}
else echo " welcome $username";
}
?>
</body>
</html>
alok
|