Page 1 of 1
checking login, cookies... help
Posted: Sun Jan 25, 2004 6:35 am
by lizlazloz
Code: Select all
<?php
if ( $_COOKIE[access] == null )
{
header("location:notloggedin.php");
exit();
}
else
{
$sql="select password from game where name= ". $_COOKIE[access] ."
and PASSWORD = password( ". $_COOKIE[passwd] ." )";
echo($sql);
$rs=mysql_query($sql,$conn)
or die("could not execute query");
$num = mysql_numrows($rs);
if($num == 0)
{
header("location:notloggedin.php");
exit();
}
}
?>
cookie access has been set as the username, and cookie passwd is the user's password. it should look thru the DB, and if they both match, all the user to carry on, else goto the not logged in page. i get this error:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/tekwar/public_html/checklogin.php on line 12
could not execute query
why?
Posted: Sun Jan 25, 2004 8:29 am
by Gen-ik
By the looks of it it's not a cookie() problem (yet) but a database connection problem. Make sure you are using mysql_connect() and mysql_select_db() correctly... I can't see them in your script anywhere??
If you are only opening one database connection then you shouldn't need to use the $conn variable when you run the query either.
:: [php_man]mysql_connect[/php_man]
:: [php_man]mysql_select_db[/php_man]
Please show your variables
Posted: Fri Dec 30, 2005 1:47 am
by dazang
Gen-ik's right, it is a mysql connect problem.
Code: Select all
$rs=mysql_query($sql,$conn)
or die("could not execute query");
So if you could please show us the file your $sql & $conn variables are located & why it is not included here?