PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?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
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.