Jump to content

Could not connect to MySQL


yrstruly

Recommended Posts

Im trying to connect to mysql database and get the folllowing error: Could not connect to MySQL:No connection could be made because the target machine actively refused it. . Im running this code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Connect to MySQL</title></head><body><?php // Script 12.2 - mysql_connect.php #2/* This script connects to the MySQL server. */ // Attempt to connect to MySQL and print out messages:if ($dbc = @mysql_connect('localhost', '', '')) { print '<p>Successfully connected to MySQL!</p>'; mysql_close($dbc); // Close the connection. } else { print '<p style="color: red;">Could not connect to MySQL:<br />' . mysql_error() . '.</p>'; } ?></body></html>Also dont work when i run it like:if ($dbc = mysql_connect('localhost','username', 'password')) { Im using Xammp

Edited by yrstruly
Link to comment
Share on other sites

I have the following code and i cant connect. usually i can if i leave out the username and password or type it in, but some how i just cant get this one right now. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Connect to MySQL</title></head><body><?php // Script 12.1 - mysql_connect.php/* This script connects to the MySQL server. */// Attempt to connect to MySQL and print out messages:if ($dbc = mysql_connect('localhost', 'b17_13305510', '')) { print '<p>Successfully connected to MySQL!</p>'; mysql_close($dbc); // Close the connection.} else { print '<p style="color: red;">Could not connect to MySQL.</p>';}?></body></html> Hers the login details and i replace it int he file as follows Your URL: http://yrstruly.byethost17.com or http://www.yrstruly.byethost17.com FTP Server : ftp.byethost17.com FTP Login : b17_13305510 FTP Password : ****** MySQL Database Name: MUST CREATE IN CPANEL MySQL Username : b17_13305510 MySQL Password : ****** MySQL Server: SEE THE CPANEL

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...