Could not query players

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
darklorda
Posts: 8
Joined: Thu Feb 23, 2012 8:49 am

Could not query players

Post 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>";
}
}
?>
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Could not query players

Post 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() ); 
Fighting for peace is declaring war on war. If you want peace be peaceful.
darklorda
Posts: 8
Joined: Thu Feb 23, 2012 8:49 am

Re: Could not query players

Post 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?
alexrules01
Posts: 175
Joined: Sun Oct 11, 2009 9:33 am

Re: Could not query players

Post 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'";
Post Reply

Return to “Beginner Help and Support”