can't access mysql with php setup
Posted 18 September 2006 - 11:18 AM
I can create a database and tables with command prompt in mysql.
On the php info script test mysql appears.
I try to access a database with php from mysql.
$dbhost = 'localhost';
$conn = mysql_connect($dbhost);
$dbname = 'petstore';
The errors I get is
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\Apache Group\Apache2\htdocs\myone2.php on line 5
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\Apache Group\Apache2\htdocs\myone2.php on line 9
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\Program Files\Apache Group\Apache2\htdocs\myone2.php on line 9Is my setup wrong?
Posted 18 September 2006 - 02:08 PM
$conn = mysql_connect($dbhost, 'root', '');
You need to define the username you want to use to connect to the MySQL server. the third paramter is where you enter the password in for the username you use.
Posted 19 September 2006 - 12:13 AM
q)When I do the server instance wizard (mysql)the security part fails on me as it claims port 3363 on is not open and to check the firewall, does this effect php ?
Posted 19 September 2006 - 10:38 AM
For your secound question yes. You'll want to open port 3363 in order for queries to be set to the database. Without the port being open PHP will not be able to send any requests to and from the MySQL database.
Also as you are using a port that is not the defualt (3306) you'll need to tell PHP which port your MySQL server is running on. So you'll want to do something like this:
$conn = mysql_connect('localhost:3363', 'root', '') or die('Unable to connect to MySQL:<br />' . mysql_error());The number after 'localhost:' is the port number in which the mysql server is running on.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users