You should always check that the calls to mysql_connect and mysql_select_db are successful. Youd do this by changing you code to be the following
$mysql_access = mysql_connect("localhost", "username" , "password") or die mysql_error();
mysql_select_db("databasename") or die mysql_error();
Now assuming that they are successful you need to put the resource identifier (in this case $mysql_access) in the query, so it'd be
$check = mysql_query("select * from `tablename` where users='$username' and password='$password',$mysql_access);
Note that there is no need to escape the $username and $password vars in your query.
HTH
GM
Originally posted by FourthChapter
Here is a simple login scipt:
<?php
$mysql_access = mysql_connect("localhost", "username" , "password");
mysql_select_db("databasename");
$check = mysql_query("select * from `tablename` where users='".$username."'
and password='".$password."'");
$exists = mysql_num_rows($check);
if($exists == 1)
{
include("secure/index.php");
}
else
{
include("denied.php");
}
?>
I get the following error:
Warning: Supplied argument is not a valid MySQL result resource in /homepages/verify.php on line 10
Wats wrong? why doesnt it work 🙁
Thanks for your help (PS im quite new to PHP)
Matt [/B]