Page 1 of 1

I cant connect to the data base.[resolved]

Posted: Fri Sep 30, 2011 4:05 pm
by gridan
Hey folks, i got a problem.

I cant connect to the data base. I use Xammpp. I followed the second video of Browser MMO. It just says "cant find players".

And i copied the code exactly. Thanks for the helpers.

Re: I cant connect to the data base.

Posted: Fri Sep 30, 2011 5:46 pm
by Jackolantern
Even though you copied the code, please post it.

Re: I cant connect to the data base.

Posted: Fri Sep 30, 2011 5:54 pm
by hallsofvallhalla
yes we will actually need to see what you are using.

Re: I cant connect to the data base.

Posted: Fri Sep 30, 2011 7:26 pm
by gridan
this is test.php

Code: Select all

<?php
include 'connect.php';

$playerinfo ="select * from players where name = 'player1'";
$playerinfo2 = mysql_query($playerinfo) or die ("could not select players");
$playerinfo3 = mysql_fetch_array($playerinfo2);

echo "Player1's email is " . $playerinfo3['email'];
echo "<br>Player1's id is " . $playerinfo3['id'];


?>

and thats connect.php

Code: Select all

<?php

$db = mysql_connect("localhost","root","") or die("Could not connect to db");
if(!$db)
die("no db");
if(!mysql_select_db("tutorial",$db))
die("No Database Selected");

?>

Re: I cant connect to the data base.

Posted: Fri Sep 30, 2011 7:52 pm
by hallsofvallhalla
i always recommend everyone watch up to video 14 before doing code but check to make sure you have a table in your DB called players. Check spelling.

Re: I cant connect to the data base.

Posted: Sat Oct 01, 2011 6:05 am
by gridan
It works. I started a new data base and it works. Thanks i think i wrote something wrong.

Re: I cant connect to the data base.

Posted: Sat Oct 01, 2011 6:54 am
by Callan S.
Sometimes I think the skill required isn't so much programming - what you don't know at the start is how to debug - where to look, what the usual problems are, etc.

Re: I cant connect to the data base.

Posted: Sat Oct 01, 2011 4:28 pm
by Jackolantern
And for the most part, PHP does not make debugging easy. It is a far cry from all the tools you have at your disposal in some other environments like .NET or Flash.