Duplicate Character Names[Solved]

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
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Duplicate Character Names[Solved]

Post by MikeD »

Well, obviously a little rusty from my 2 weeks away :P.

Had to create a new DB since I forgot to save mine on the flash drive, made table names and a few column names differently. Now I am stuck on this little gem.

I've tested to make sure the $warrior variable was valid, which it is, it comes from the register form.

Code: Select all

$warrior=$_POST['warrior'];

$isplayer="SELECT * from characters where character=$warrior]";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
Keeps coming up with the die statement "Could not query players table", when trying to create a player. This worked just fine on my old laptop and with the old DB.
Last edited by MikeD on Thu Oct 20, 2011 1:55 am, edited 1 time in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Duplicate Character Names

Post by SpiritWebb »

MikeD wrote:Well, obviously a little rusty from my 2 weeks away :P.

Had to create a new DB since I forgot to save mine on the flash drive, made table names and a few column names differently. Now I am stuck on this little gem.

I've tested to make sure the $warrior variable was valid, which it is, it comes from the register form.

Code: Select all

$warrior=$_POST['warrior'];

$isplayer="SELECT * from characters where character=$warrior]";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
Keeps coming up with the die statement "Could not query players table", when trying to create a player. This worked just fine on my old laptop and with the old DB.
You have a [ after your $warrior call, remove that and try again!!
Image

Image
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Duplicate Character Names

Post by Chris »

SpiritWebb wrote:
MikeD wrote:Well, obviously a little rusty from my 2 weeks away :P.

Had to create a new DB since I forgot to save mine on the flash drive, made table names and a few column names differently. Now I am stuck on this little gem.

I've tested to make sure the $warrior variable was valid, which it is, it comes from the register form.

Code: Select all

$warrior=$_POST['warrior'];

$isplayer="SELECT * from characters where character=$warrior]";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
Keeps coming up with the die statement "Could not query players table", when trying to create a player. This worked just fine on my old laptop and with the old DB.
You have a [ after your $warrior call, remove that and try again!!
It's actaully a ].

Code: Select all

$warrior=$_POST['warrior'];

$isplayer="SELECT * FROM `characters` WHERE `character`='$warrior'";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
 
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Re: Duplicate Character Names

Post by MikeD »

Nope doesn't work, that was just a typo, tried it with the post, didn't work either.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Duplicate Character Names

Post by SpiritWebb »

Are you including your connect file?

Code: Select all

<?php include_once "connect.php"; ?>
Image

Image
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Re: Duplicate Character Names

Post by MikeD »

yessir
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Duplicate Character Names

Post by SpiritWebb »

At the end of your "Could not query players table."

Put a . mysql_error().

Code: Select all

$warrior=$_POST['warrior'];

$isplayer="SELECT * from characters where character=$warrior]";
$isplayer2=mysql_query($isplayer) or die("Could not query players table" . mysql_error());
$isplayer3=mysql_fetch_array($isplayer2);
To better see whats going on
Image

Image
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Re: Duplicate Character Names

Post by MikeD »

Could not query players tableYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=test' at line 1
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Duplicate Character Names

Post by Chris »

Code: Select all

$isplayer="SELECT * FROM `characters` WHERE `character`='" . mysql_real_escape_string($warrior) . "'"; 
Seems like it's an error caused by injection.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: Duplicate Character Names

Post by Ark »

MikeD wrote: near '=test' at line 1
is that supposed to be like 'test' instead oof '=test'. xD

$isplayer="SELECT * from characters where character='$warrior'";
Orgullo Catracho
Post Reply

Return to “Beginner Help and Support”