Connecion issue


Posted on 16th Feb 2014 07:03 pm by admin

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?

No comments posted yet

Your Answer:

Login to answer
173 Like 32 Dislike
Previous forums Next forums
Other forums

Mail from PHP form not always ending up in my inbox?
Hi guys,

I'm a real newbie to PHP and have managed to put together a simple mail form that se

Error: SQL Syntax; Line 1
Code:

<?php require "global_settings.php"; ?>
<title&g

Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.

I need to create a drop

php/mysql problem
Hey all,

Problem: im trying to setup a shop where people can use a drop-down list to select t

Why is this function returning a false value when it shouldn't be??
This is in an include file. I want it to check a value in an html form and see if it's just white s

What is SAP Avatar ?
Hi All,

This G.Satish , my boss asked me to explore on SAP Avatar. I searced in internet

Allowing ' and "
Hello everyone,

I am creating a form where users submit information to go into a database. I

Need to write a cookie with a url var
Not sure if its possible, but I need to write a cookie with a url.

So this would write 2232 a

simplexml and xpath - Need some help
Hello,

I am trying to parse an xml which comes back from Amazon and I am trying to know how m

Problem with shopcart code
Hello, I am having a bit of trouble being able to add a product to my shopcart. My mysql database i

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash