Boa tarde, Sou novo forum e tenho uma dúvida ... Tenho pagina de autenticação porem quando digito o usuario e senha me retorna o seguinte erro ... "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND pass=NULL' at line 1" Segue o codigo da minha página ... index.php <?php require_once('Connections/config.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['user'])) {
$loginUsername=$_POST['user'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index1.php";
$MM_redirectLoginFailed = "index2.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_config, $config);
$LoginRS__query=sprintf("SELECT `user`, pass FROM authen WHERE `user`=%s AND pass=%s",
GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $config) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<?php include"header1.php" ?>
<div id="content">
<div id="conteudo">
<div id="box1">
<div id="loginbox">
<div id="login">
<form action="<?php echo $loginFormAction; ?>" method="POST" id="boxlogin"><table width="200" border="1">
<tr>
<td colspan="2" align="center">Login:</td>
</tr>
<tr>
<td>User:</td>
<td><label for="user"></label>
<input type="text" name="user" id="user" /></td>
</tr>
<tr>
<td>Password:</td>
<td><label for="pass"></label>
<input type="password" name="pass" id="pass" /></td>
</tr>
<tr>
<td> </td>
<td align="right"><input type="submit" name="login" id="login2" value="Login" /></td>
</tr>
</table>
</form>
</div><!--login-->
</div><!--loginbox-->
</div><!--box1-->
</div><!--conteudo-->
</div><!--conteudo-->
<?php include"nav/sidebar.php"?>
<div id="divclear"></div>
</div><!--content-->
<div id="footer">
<ul>
<li><a href="http://www.diablo3.com" target="_blank"><img src="imagens/blizzard.jpg"/></a></li>
<li><p>©2010 - Blizzard Entertainment.<br />
All rights reserved.</li></p>
<li><a href="http://www.diablo3.com" target="_blank"><img src="imagens/blizzard.jpg"/></a></li>
</ul>
</div><!--footer-->
</div><!--box-->
</body>
</html> Por favor me ajudem ... Aguardo.