problem with strings (SOLVED)
problem with strings (SOLVED)
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?
<?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.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: problem with strings
change
to
Code: Select all
$playerinfo2 = mysql_query($playerinfo) or die("could not get player stats!");
Code: Select all
$playerinfo2 = mysql_query($playerinfo) or die(mysql_error());
Re: problem with strings
Now I get error:
Access denied for user 'apache'@'localhost' (using password: NO)
Access denied for user 'apache'@'localhost' (using password: NO)
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: problem with strings
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
Re: problem with strings
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.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.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: problem with strings
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
I do have password, and password is set on connect.php
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: problem with strings
<?php
$dbhost = 'localhost';
$dbuser = '967798';
$dbpass = 'sarabeba';
$dbname = '967798';
?>
$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.
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: problem with strings
That the full connect file?SFC wrote:<?php
$dbhost = 'localhost';
$dbuser = '967798';
$dbpass = 'sarabeba';
$dbname = '967798';
?>