problem with strings (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
SFC
Posts: 16
Joined: Mon Apr 06, 2015 6:32 pm

problem with strings (SOLVED)

Post 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?
Last edited by SFC on Fri Apr 10, 2015 4:03 pm, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: problem with strings

Post 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());
SFC
Posts: 16
Joined: Mon Apr 06, 2015 6:32 pm

Re: problem with strings

Post by SFC »

Now I get error:
Access denied for user 'apache'@'localhost' (using password: NO)
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: problem with strings

Post 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.
The indelible lord of tl;dr
SFC
Posts: 16
Joined: Mon Apr 06, 2015 6:32 pm

Re: problem with strings

Post 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.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: problem with strings

Post 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.
SFC
Posts: 16
Joined: Mon Apr 06, 2015 6:32 pm

Re: problem with strings

Post by SFC »

I do have password, and password is set on connect.php
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: problem with strings

Post by SpiritWebb »

Post your connect.php file please.
Image

Image
SFC
Posts: 16
Joined: Mon Apr 06, 2015 6:32 pm

Re: problem with strings

Post by SFC »

<?php
$dbhost = 'localhost';
$dbuser = '967798';
$dbpass = 'sarabeba';
$dbname = '967798';
?>
Last edited by SFC on Mon Apr 13, 2015 7:34 am, edited 2 times in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: problem with strings

Post by SpiritWebb »

SFC wrote:<?php
$dbhost = 'localhost';
$dbuser = '967798';
$dbpass = 'sarabeba';
$dbname = '967798';
?>
That the full connect file?
Image

Image
Post Reply

Return to “Beginner Help and Support”