I was working in some code in a PHP course I assisted, in a LAMP environment, and worked without problems. After the course, I took my code home and ran it on a WAMPServer, and for some reason, mysql_connect is not accepting some variables as arguments. I know this because I tried giving the parameters to mysql_connect by hand and the connection works. Also, I echoed all four variables and they print out OK.
I am new to PHP, but this doesnt make any sense to me.
The code:
functions.php
<?php
require ("config.php");
function conectardb () {
mysql_connect ($server, $login, $pass);
mysql_select_db ($db);
}
?>
config.php
<?php
$login = "root" ;
$pass = "" ;
$server = "localhost";
$db = "testing";
?>
I've tried replacing the plain arguments by their variables one by one, and found out the code works until this point:
function conectardb () {
mysql_connect ($server, "root", $pass);
mysql_select_db ("testing");
}
If I use $login or $db, the connection will not work. Any ideas? This is driving me crazy.