Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql_connect(): No such file or directory in /opt/lampp/htdocs/

I have installed XAMPP on my Ubuntu 14.0.04 and I'm trying to connect to my MySQL server from PHP file but I'm getting an error:

Warning: mysql_connect(): No such file or directory in /opt/lampp/htdocs/value.php on line 3
not connected

my value.php file contains

<?php

$con = mysql_connect('localhost:3307', 'root', '');
if ($con) echo 'Connected';
else echo 'not connected';
---
?>

and my MySQL server is up and running and my server is also running.

like image 973
Tutorials For Beginners Avatar asked May 24 '15 09:05

Tutorials For Beginners


1 Answers

Which version of mysql are you using?

Try this

 127.0.0.1:your-port-number

like

$con = mysql_connect('127.0.0.1:3307', 'root', ''); // or 3306 whatever your port number is

instead of localhost

I too had this problem, but this link helped me Warning: mysql_connect()

like image 80
Abhinav Avatar answered Oct 14 '22 07:10

Abhinav