docker-lamp icon indicating copy to clipboard operation
docker-lamp copied to clipboard

How to connect to database?

Open ghost opened this issue 8 years ago • 2 comments

#Im getting: Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/html/test.php:2 Stack trace: #0 {main} thrown in /var/www/html/test.php on line 2

<?php
$link = mysql_connect('localhost', 'root', 'pass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

ghost avatar Oct 10 '17 20:10 ghost

Please do not use mysql_connect use PDO

naga3 avatar Oct 11 '17 01:10 naga3

And the hostname I think should be "mysql" same as in docker-compose

FDiskas avatar Nov 12 '17 12:11 FDiskas