Hi everyone! :)
I'm just starting out with php and mysql, and encountered the following problem:
I have installed:
Apache 2.2.8-1
PHP 5.2.5-7
MySQL 5.0.51-3
on an Arch-Linux system.
Apache and PHP are working: I tested that.
I can log in to mysql from the commandline; I made a small database for a test.
When I try to connect to this database from a webpage with this php-code:
<?php
require_once('db_login.php');
// connect
$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die ("Kan geen verbinding krijgen met de database: <br />".mysql_error());
};
// select database
$db_select=mysql_select($db_database);
if (!$db_select){
die ("Database niet gevonden: <br />".mysql_error());
};
mysql_close($connection);
echo "succes !";
?>
file db_login.php:
<?php
$db_host='127.0.0.1';
$db_database='bandjes';
$db_username='ko';
$db_password='Kobus';
?>
I get this error:
Kan geen verbinding krijgen met de database:
Lost connection to MySQL server at 'reading initial communication packet', system error: 0
So there's an error on the mysql_connect() function, but I don't understand what the error is...
Anyone any idea?? :?: