English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Well ok, i should rather ask, how to connect to mysql server without using sockets. This is how i connect at this time:
require_once('DB.php');

function connect_to_manish_db(){
global $__db;
$mode = DB_FETCHMODE_ASSOC;
$user = 'root';
$pass = '';
$host = 'localhost';
$db_name = 'whatevernameitis';
$dsn = "mysql://$user:$pass@$host/$db_name";
$__db = DB::connect($dsn, true);
return $__db;
}

?>

I also tried this way :

function dbConnectionManish(){
global $___dbConn;
if(!$___dbConn){
$___dbConn = mysql_connect('localhost','root','');
if(!$___dbConn){return false;}
$selectDB = mysql_select_db('whateverdbnameis');
if(!$selectDB){return false;}
}
return $___dbConn;
}

I am hosting with www.streamline.net, using linux server and PHP.

I get this error very often:

Warning: mysql_connect(): Can't connect to MySQL server on 'mysql8.streamline.net' (4) in /home/fhlinux191/m/manish.sentosajaipur.com/user/htdocs/include/functions.common.php on line 6...
streamline line says use tcp

2006-07-20 08:11:19 · 3 answers · asked by Manish 5 in Computers & Internet Programming & Design

Full description of the error:
Warning: mysql_connect(): Can't connect to MySQL server on 'mysql8.streamline.net' (4) in /home/fhlinux191/m/manish.sentosajaipur.com/user/htdocs/include/functions.common.php on line 6

Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/fhlinux191/m/manish.sentosajaipur.com/user/htdocs/include/kbserver.php on line 58

Warning: mysql_query(): A link to the server could not be established in /home/fhlinux191/m/manish.sentosajaipur.com/user/htdocs/include/kbserver.php on line 58
Query failed.Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

2006-07-20 08:11:36 · update #1

3 answers

First, I recommend using PDO to manage your connections. It is really easy to connect - $conn = new PDO ( "mysql: host=serverURL; dbname=db", $user, $pass);

the socket issue is probably a limit on incoming connections. You can set that up through your MySQL configuration, if you use PDO you can also set it to use persistant connections which will allow you to set the max number of incoming sql connections to match the max number of children Apache can have.

more info: http://us3.php.net/manual/en/ref.pdo.php

2006-07-20 09:28:04 · answer #1 · answered by John J 6 · 0 0

Heres how I do it with PHP:

$db=mysql_connect("localhost","username","password");
mysql_select_db("databasename",$db);

$sql="SELECT * FROM table";
$res=mysql_query($sql);


?>

and go from there. If you want tighter security then define your connection user, pass and host and include that file or call it through a function.

2006-07-20 08:16:16 · answer #2 · answered by rob 3 · 0 0

there are various possibilities.the 1st and in elementary terms element i will recommend is that confirm you has set up a suited ODBC connection. pass to regulate Panel > Administrative techniques > ODBC to create a ODBC connection.

2016-11-02 10:18:50 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers