Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.