php couldnt connect to mysql

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Abyssal
Posts: 74
Joined: Wed Mar 10, 2010 1:53 am

php couldnt connect to mysql

Post by Abyssal »

hello there.

i have a problem with my website. i try to add top pvp / top pk but i cant because php doesnt connect to mysql. here is my config files:

stats.php:

Code: Select all

<?php     $db_user = "root";     $db_pass = "my password here";     $db_name = "l2jdb";     $db_serv = "my ip here";      $res = mysql_connect ( $db_serv, $db_user, $db_pass ) or die ("Coudn't connect to [$db_serv]");     $resdb = mysql_select_db ( "$db_name",$res );      return $res;  ?>
status.php
<?php
$server = "my ip here";
$portg = "7777";
$portl = "2106";
$timeout = "1";
?>

i use this website:

http://www.maxcheaters.com/forum/index. ... c=115992.0

i use freehostia and my server is dedicated. ive also enabled the mysql remote access in my server machine and ive opened the ports 80 and 8000.

i just hope somebody is going to answer because i know there are only a few people really willing to help newbies. so im almost sure the only post in this topic will be mine.
Abyssal
Posts: 74
Joined: Wed Mar 10, 2010 1:53 am

Re: php couldnt connect to mysql

Post by Abyssal »

of course nobody answering as always. but this time i will keep replying until you answer because you ve never helped me like i wanted in this forum.
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: php couldnt connect to mysql

Post by JIV »

and what? this is php forum? why dont you ask person who made it?
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: php couldnt connect to mysql

Post by UnAfraid »

You cant use return because it can be used in function only and $res will return an object if successfully connected to mysql server on fail will return false.
take a look on this http://php.net/mysql_connect
and try this

Code: Select all

 <?php     $db_user = "root";     $db_pass = "my password here";     $db_name = "l2jdb";     $db_serv = "my ip here";      $res = mysql_connect ($db_serv, $db_user, $db_pass);    $resdb = mysql_select_db ($db_name, $res);     if (!$res || !$resdb)        die(mysql_error());?>
if you use root user it will not work because it is limited to work on localhost you need to create a new user and give him access to connect from remote ip i think thats your problem.

if that's your problem try this

Code: Select all

CREATE USER 'myname'@'remote.server.address' IDENTIFIED BY 'mypass';GRANT ALL PRIVILEGES ON l2jdb.* to 'myname'@'remote.server.address';FLUSH PRIVILEGES;
Image
Abyssal
Posts: 74
Joined: Wed Mar 10, 2010 1:53 am

Re: php couldnt connect to mysql

Post by Abyssal »

no its ok the problem is i opened the wrong port. i hadnt open the mysql port. i solved it :)
Post Reply