PDA

View Full Version : Cannot connect to MySQL


kaisellgren
07-11-2006, 07:15 PM
Hi,

Main Code:
$c_hostname = $_POST["c_hostname"];
$c_database = $_POST["c_database"];
$c_username = $_POST["c_username"];
$c_password = $_POST["c_password"];
require("mysql_connect.php");

mysql_connect.php
$link = @mysql_connect($c_hostname,$c_username,$c_password, $c_database) or die("error2.".mysql_error());
@mysql_select_db($c_database,$link) or die("error.".mysql_error());

It gives me errors saying Access denied for user 'ODBC'@'localhost' (using password: NO)

Help?
It seems that mysql_connect.php cannot get the c_ variables? How to do that it can get them?

arnyinc
07-11-2006, 08:06 PM
I don't think you want to specify the database in your mysql_connect() function call. Just the username, password, and hostname.

Have you tried connecting to the database using another interface than PHP? That will verify you are using a valid username, password, and hostname.

kaisellgren
07-11-2006, 09:27 PM
Oh no. The values are correct. I have the server on my own cpu. Checked thousands of times, they are correct. If I put echo $c_hostname in the main script, it will print the corrent text, BUT if I put the same echo in the mysql_connec.tphp it will print nothing!