MYSQL Server Connection Error

stormprograms

New Member
Messages
5
Reaction score
0
Points
0
Okay so I have been trying to get my config.php to act as my establish for my MYSQL but I can't get the MYSQL Connect to work. When I run my code through codepad.org I get this error:
Code:
Fatal error: Call to undefined function mysql_connect() on line 7

Now the code for my config.php is:

Code:
<?php
//Mysql connection
	DEFINE ('DB_USER', '***********'); // Insert your database username into the quotes.
	DEFINE ('DB_PASSWORD', '*********'); // Insert your database password into the quotes.
	DEFINE ('DB_HOST', '******************'); // This will most likely stay the same.
	DEFINE ('DB_NAME', '************');// Insert your actual database name in the quotes.
	$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
	mysql_select_db (**************) OR die('Could not select the database: ' . mysql_error() );
//script basic variables
	$timeout = 5;
?>

Still I cant figure out what's wrong

The error code when you try to access it through a url is:

Code:
Warning:  mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'mysql11.000webhost.com' (4) in /home/palace/runeleague/storm/config.php on line 7
Could not connect to MySQL: Can't connect to MySQL server on 'mysql11.000webhost.com' (4)
 

xadrieth

New Member
Messages
62
Reaction score
1
Points
0
I'm not sure, but judging from the error, the "mysql_connect()" function might now be disabled.

use "mysqli_connect".

syntax is like this:
PHP:
$dbc = mysqli_connect('localhost', 'root', 'pw', 'data');
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
Code:
MySQL server on 'mysql11.000webhost.com'
that's your error

the server for x10 is:
localhost
or
mysql.x10hosting.com

PHP:
<?php
//Mysql connection
	DEFINE ('DB_USER', '***********'); // Insert your database username into the quotes.
	DEFINE ('DB_PASSWORD', '*********'); // Insert your database password into the quotes.
	DEFINE ('DB_HOST', 'localhost'); // This will most likely stay the same.
	DEFINE ('DB_NAME', '************');// Insert your actual database name in the quotes.
	$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
	mysql_select_db (**************) OR die('Could not select the database: ' . mysql_error() );
//script basic variables
	$timeout = 5;
?>
and just fill out the rest
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Quick pointer. Do NOT define() passwords! They will be available everywhere in the script and present a large security risk.

Also, why are you connecting to another hosts mysql?
 

stormprograms

New Member
Messages
5
Reaction score
0
Points
0
Currently x10hosting seems to block port 43594 but I just need some assistance still. I will use a x10hosting MYSQL for now but how can I resolve this?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Remote MySQL is currently disabled on x10 free accounts. You have three major choices:
  • Move everything to x10Hoting;
  • Code or modify an xmlrpc interface so that the queries are executed on the server where your DB resides, and the remote script returns a xml or JSON data feed. Use a tool such as MySQL-PHP Suite (MySQL-PHP Client & MySQL-PHP Server) to remotely execute your queries and get the results locally (connection unencrypted though);
  • Buy a premium package.
 
Top