Page 1 of 1

Could not query players

Posted: Sat Feb 25, 2012 10:07 am
by darklorda
mm i have this problem it says Could not query players it must say Wrong username and password go back .. :roll:

<?php
include_once 'connect.php';
session_start();

if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);

$query = "selet name,password from players where name='$player' and '$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;

echo "<big>Logget in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>

Re: Could not query players

Posted: Sat Feb 25, 2012 11:11 am
by Chris
Use mysql_error() to see what's wrong with the query:

Code: Select all

$result = mysql_query($query) or die("Could not query players. " . mysql_error() ); 

Re: Could not query players

Posted: Sat Feb 25, 2012 11:17 am
by darklorda
it says Could not query players. 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 'selet name,password from players where name='Klimentovv' and '1aabac6d068eef6a7b' at line 1 what i should dO?

Re: Could not query players

Posted: Sat Feb 25, 2012 12:47 pm
by alexrules01
$query = "select name,password from players where name='$player' and password='$password'";

Check whats bolded. i believe thats your error.

Also, if you are just choosing the player, you don't need to query the password aswell. Unless you need it for a specific purpose. So instead, I think you should be fine using this:

$query = "select name from players where name='$player' and password='$password'";