Page 1 of 1

problem with strings (SOLVED)

Posted: Mon Apr 06, 2015 6:47 pm
by SFC
I have watched some youtube videos of Browser-Based MMORPG Tutorial, and on 4a video I encounter a problem.. this is the code:

<?php
include 'connect.php';
$playerinfo = "SELECT * FROM players WHERE username = 'player1'";
$playerinfo2 = mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3 = mysql_fetch_array($playerinfo2);
...etc...

and error says: could not get player stats!
So I assume there is error in line 3? Note to say: my db table is players and row is username, instead of just name as it is mention in tutorial.
connect.php is well set as I did manage to connect to my db and insert various names when registrateing. Also, I dont know is it important, but my host is not on coputer, I put files online and simple manage db and files on hosting server (easyer for me since I work from several different computers such as at home, work or my parents house).

So do I not see something obvius or is something else?

Re: problem with strings

Posted: Mon Apr 06, 2015 7:06 pm
by hallsofvallhalla
change

Code: Select all

$playerinfo2 = mysql_query($playerinfo) or die("could not get player stats!");
to

Code: Select all

$playerinfo2 = mysql_query($playerinfo) or die(mysql_error());

Re: problem with strings

Posted: Mon Apr 06, 2015 7:31 pm
by SFC
Now I get error:
Access denied for user 'apache'@'localhost' (using password: NO)

Re: problem with strings

Posted: Tue Apr 07, 2015 2:01 am
by Jackolantern
The MySQL database is denying you access. Did you just type in the credentials in the video? You need to actually set up a user in your database and add fill in the credentials in your connect.php script.

Re: problem with strings

Posted: Tue Apr 07, 2015 3:50 pm
by SFC
Jackolantern wrote:The MySQL database is denying you access. Did you just type in the credentials in the video? You need to actually set up a user in your database and add fill in the credentials in your connect.php script.
I did set up a user in database. One I created as player1 as mention in video, and 2 others from register page, so connect.php is connected with my databases, otherwise it would not import users who register into databases.

Re: problem with strings

Posted: Tue Apr 07, 2015 7:00 pm
by hallsofvallhalla
No it is your credentials. Root and no password. Are you sure your password is blank? The login you use for PHPMyAdmin should be the one in your connect file.

Re: problem with strings

Posted: Tue Apr 07, 2015 7:25 pm
by SFC
I do have password, and password is set on connect.php

Re: problem with strings

Posted: Tue Apr 07, 2015 8:10 pm
by SpiritWebb
Post your connect.php file please.

Re: problem with strings

Posted: Tue Apr 07, 2015 8:37 pm
by SFC
<?php
$dbhost = 'localhost';
$dbuser = '967798';
$dbpass = 'sarabeba';
$dbname = '967798';
?>

Re: problem with strings

Posted: Tue Apr 07, 2015 9:19 pm
by SpiritWebb
SFC wrote:<?php
$dbhost = 'localhost';
$dbuser = '967798';
$dbpass = 'sarabeba';
$dbname = '967798';
?>
That the full connect file?