I keep getting a parse error on the following line:
PHP Code:
while($row = mysql_fetch_array['result'])
I downloaded the script (i cant remember where from now) but I have been trying to alter to to get it to work, but I'm not the usuage of
PHP Code:
mysql_fetch_array['result']
like that before
PHP Code:
<?
include"settings.php";
if (isset($submit)) // name of submit button
{ $query = "select * from logintable where username='$username' and password='$password'";
echo "\n\nQuery:".$query;
$result = mysql_query($query);
echo "\n\nResult:".$result;
$isAuth = false; //set to false originally
while($row = mysql_fetch_array['result'])
{
echo $row['username'];
echo $row['password'];
if($row['username'] == $username)
//above row checks to see if username/password combination exists
{
$isAuth = true;
session_start();
session_register('username');
}
}
if($isAuth)
{
print "logged in successfully<br>";
print "<A href='index.php'>Go to Admin Panel</a>";
}
else
//if login/pass does not exist
{
print "Wrong username or password";
}
}
?>
Or if anyone can direct me to simple easy to use login script for admin system it would be greatly appreciated,
but i got confused as to whether it was right or not because when i change it to
PHP Code:
while($row = mysql_fetch_array($result))
i get the following error messages
form submitted Query:select * from logintable where username='username' and password='password' Warning: Access denied for user: 'urbanaca@localhost' (Using password: NO) in /home/urbanaca/public_html/test/authenticate.php on line 21 Warning: MySQL Connection Failed: Access denied for user: 'urbanaca@localhost' (Using password: NO) in /home/urbanaca/public_html/test/authenticate.php on line 21 Warning: MySQL: A link to the server could not be established in /home/urbanaca/public_html/test/authenticate.php on line 21 Result: Warning: Supplied argument is not a valid MySQL result resource in /home/urbanaca/public_html/test/authenticate.php on line 25 Wrong username or password
I've used some different connection code from another file i had work and I don't get the errors now, but i've got a different problem which i will post if it continues to prove a problem
The connection info is all correct, when i test the sql in php admin it is fine,
but i think it gives false for while($row = mysql_fetch_array($result))
doesn't go into the while loop and goes straight into print "Wrong username or password"; because $auth is false
any idead anyone?
Cheers Neil
PHP Code:
<?
# PULL ADDITIONAL FILES
include_once (".././settings.php");
# CONNECT TO THE MySQL SERVER
$link = mysql_connect($host,$user,$password);
# SELECT THE DATABASE NEEDED
mysql_select_db("$base");
if (isset($submit)) // name of submit button
{
echo "form submitted\n\n";
$query = "select * from logintable where username='$username' and password='$password'";
echo "\t\tQuery:".$query;
// $db = mysql_pconnect($dbHost, $dbUser, $dbPass);
// mysql_select_db($dbName, $db);
$result = mysql_query($query);
//echo "\t\tResult:".$result;
$isAuth = false; //set to false originally
while($row = mysql_fetch_array($result))
{
//echo $row['username'];
//echo $row['password'];
if($row['username'] == $username)
//above row checks to see if username/password combination exists
{
$isAuth = true;
session_start();
session_register('username');
}
}
if($isAuth)
{
print "logged in successfully<br>";
print "<A href='index.php'>Go to Admin Panel</a>";
}
else
//if login/pass does not exist
{
print "Wrong username or password";
}
}
?>
Bookmarks