i got this error msg in online... how to solve this
problem... i couldnot find out as soon as possible send me
answer or idea


COULD NOT ABLE TO CONNECT DATABASE .
Can't connect to local MySQL server through socket
'/usr/local/mysql-5.0/data/mysql.sock' (2)

Answers were Sorted based on User's Feedback



i got this error msg in online... how to solve this problem... i couldnot find out as soon as possi..

Answer / asheesh

database connection was not established yet that's why this
error is occuring.

$con=mysql_connect("localhost","root","password") or die
(mysql_error());
$link=mysql_select_db('test',$con);
if(!$link)
{
die(mysql_error());
}
"root" is the user name
"test" is the database name

Is This Answer Correct ?    4 Yes 0 No

i got this error msg in online... how to solve this problem... i couldnot find out as soon as possi..

Answer / ritu

First you have to make a database connection. coding is below mention:
first u have to create a connection to server like:
mysql_connect("localhost","root","");

then select the database like:
mysql_select_db("database_name");

localhost is default server name.
root is default user name.
"" is default password. it means password is blank.

Is This Answer Correct ?    2 Yes 1 No

i got this error msg in online... how to solve this problem... i couldnot find out as soon as possi..

Answer / shweta

database name must be wrong or you can use IP address
instead of 'localhost'.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What are interfaces in php?

0 Answers  


Explain what is the static variable in function useful for?

0 Answers  


Explain me how to include a file to a php page?

0 Answers  


How to remove the new line character from the end of a text line in php?

0 Answers  


Explain me is it possible to destroy a cookie?

0 Answers  






List some sorting functions in php?

0 Answers  


Is php is dying?

0 Answers  


How to redirect https to http url and vice versa in .htaccess?

0 Answers  


how long a default session stay in php?

8 Answers  


For printing out strings, there are echo, print and printf. Explain the differences.

3 Answers  


How to include variables in double-quoted strings in php?

0 Answers  


Tell me what are the __construct() and __destruct() methods in a php class?

0 Answers  


Categories