Page 1 of 1
Duplicate Character Names[Solved]
Posted: Tue Oct 18, 2011 8:32 pm
by MikeD
Well, obviously a little rusty from my 2 weeks away

.
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.
Re: Duplicate Character Names
Posted: Tue Oct 18, 2011 8:34 pm
by SpiritWebb
MikeD wrote:Well, obviously a little rusty from my 2 weeks away

.
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!!
Re: Duplicate Character Names
Posted: Tue Oct 18, 2011 9:08 pm
by Chris
SpiritWebb wrote:MikeD wrote:Well, obviously a little rusty from my 2 weeks away

.
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);
Re: Duplicate Character Names
Posted: Tue Oct 18, 2011 11:39 pm
by MikeD
Nope doesn't work, that was just a typo, tried it with the post, didn't work either.
Re: Duplicate Character Names
Posted: Tue Oct 18, 2011 11:45 pm
by SpiritWebb
Are you including your connect file?
Code: Select all
<?php include_once "connect.php"; ?>
Re: Duplicate Character Names
Posted: Wed Oct 19, 2011 12:42 am
by MikeD
yessir
Re: Duplicate Character Names
Posted: Wed Oct 19, 2011 2:49 am
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
Re: Duplicate Character Names
Posted: Wed Oct 19, 2011 1:32 pm
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
Re: Duplicate Character Names
Posted: Wed Oct 19, 2011 1:40 pm
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.
Re: Duplicate Character Names
Posted: Wed Oct 19, 2011 1:41 pm
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'";