Jump to content

Connecion issue


toolman

Recommended Posts

Hi,

 

For some reason, I keep getting this error when trying to connect:

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on...

Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket...

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established...

 

This is my php code:

 

<?php
//database connection settings
$db_username = "test";
$db_password = "test";
$db_host = "test";
$db_name = "test";

$connection = mysql_connect($db_username, $db_password, $db_host);
if(!$connection){
echo"Cannot connect to database! Please check the settings";
}

else{
echo"Database Connection Successful";
}

mysql_select_db($db_name);
echo"Database Connection Successful";

?>

 

Any ideas whats wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/178969-connecion-issue/
Share on other sites

The three parameters in the mysql_connect() function call are not in the order that you tried. The only way to effectively use any programming language is to read the documentation for whatever small part of it you are attempting to use - http://php.net/mysql_connect

Link to comment
https://forums.phpfreaks.com/topic/178969-connecion-issue/#findComment-944321
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.