Ok, I'm coding a new script, but experiencing a problem with sql.
SQL
Error I'm getting
So theres something wrong with this peace of coding
$userquery = "SELECT * FROM `users` WHERE site='".$site."', `name` = '".$name."' AND pass = LIKE '".$pass."'";
$userresult = mysql_query($userquery);
$userotvet = mysql_fetch_array($userresult);
Someone please correct me on fixing this error?
Code:
<?
include("../config.php");
include("../style.php");
$site = $_POST['site'];
$site=strtolower($site);
$query = "SELECT * FROM `users` WHERE `site` = '".$site."'";
$result = mysql_query($query);
$otvet = mysql_fetch_array($result);
if($otvet['site']){
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<?
echo "<head>\n";
echo "<title>Login@".$site."</title>\n";
echo $style;
echo "<meta name=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />\n";
echo "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />\n";
echo "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
echo "</head>\n";
echo "<body>\n";
$userquery = "SELECT * FROM `users` WHERE site='".$site."', `name` = '".$name."' AND pass = LIKE '".$pass."'";
$userresult = mysql_query($userquery);
$userotvet = mysql_fetch_array($userresult);
if($userotvet['name']){
echo "Hi ".$name.", welcome to ".$site." :)
\n";
echo "<a href=\"enter.php?site=$site&name=$name&pass=$pass\">Enter ".$site."</a>\n";
echo "<div class=\"foot\">\n";
echo "© WapX ".date ("Y")."";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
else
{
echo "Not Logged in.
\n";
echo "Please register or try loging in again.
\n";
echo "<a href=\"index.php?site=$site\">Home</a>\n";
echo "<div class=\"foot\">\n";
echo "© WapX ".date ("Y")."";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
}
else
{
header("location: error/notfound.php");
exit();
}
?>
Code:
CREATE TABLE `users` ( `id` int(4) NOT NULL auto_increment, `site` varchar(15) NOT NULL default '', `name` varchar(15) NOT NULL default '', `pass` varchar(30) NOT NULL default '', `birthday` varchar(15) NOT NULL default '', `sex` varchar(8) NOT NULL default '', `country` varchar(20) NOT NULL default '', `province` varchar(20) NOT NULL default '', `level` char(1) NOT NULL default '0', `rtime` varchar(30) NOT NULL default '', `ip` text, `soft` text, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/user/public_html/script/sites/login.php on line 61[/b]
$userquery = "SELECT * FROM `users` WHERE site='".$site."', `name` = '".$name."' AND pass = LIKE '".$pass."'";
$userresult = mysql_query($userquery);
$userotvet = mysql_fetch_array($userresult);
Someone please correct me on fixing this error?

Comment