while trying to make a php ecommerce site for a local variety group to which im a member (enough of the life get on with the code) i have stumbled accross a problem with users logging in .
i could not get my head around the joinging arrays for the shop so decided to take to the mysql route of carting.
in making so i decided to give each user a user account which they obviously create. HOWEVER... while connecting to the database to ask if their usernames and passwords match i get the following
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/keith/public_html/users/processlogin.php on line 119
Invalid Username
Password Incorrect
now i have been playing with this for hours and need some help now. below is my code which i extract from the database with and no matter what i do i get the error above.
in the database username is indexed to ensure that no duplicates are created as well as e-mail address's to save on database clutter with multiple users.
i have tried fetch_row fetch_array fetch_field and i get same result from each of them.
sample database record - hopefuly looks better once submitted
mysql> select * from hvgUsers;
+----------+---------------+---------------+-----------+--------+----------+----------+----+----------------------+
| password | address_line1 | address_line2 | town | county | pcode | username | id | email |
+----------+---------------+---------------+-----------+--------+----------+----------+----+----------------------+
| Testing | Hardy | ----- | Maidstone | Kent | ME14 2SJ | ID | 7 | bob |
| testing | Hardy Street | ----- | Maidstone | Kent | ME14 2SJ | PodMan99 | 6 | keithjasper@blueyond |
+----------+---------------+---------------+-----------+--------+----------+----------+----+----------------------+
2 rows in set (0.00 sec)
php CODE
<?
$login = "select * from hvgUsers";
$text = mysql_query($login);
$row = mysql_fetch_array($text);
if ('$row[6]' !== '$username')
{
echo ("<BR>Invalid Username");
}
if ('$row[0]' !== '$password')
{
echo ("<BR>Password Incorrect");
}
else echo("Login Successful");
?>
thanks in advance peoples