how to make it work? MySql -help needed...please
Posted: Sun Feb 15, 2004 11:05 am
When i use the following two lines i can get connected to my MySql DB without any problem..
However, when i try to use the following piece of code to get connected to my MySql DB it gives me an error.
This is the error messege i receive:
So, i did remove these lines of code from my db_connect.php file :
I got this reply after i tried that:
So, it is quite clear my php code cant get connected to DB. Why is that being happening where i m using the same username and password?
This is how i always get my Mysql DB up and running...do you see any problem here ? or do you want to suggest a better way that is more widely used?
Can anybody sheds some light?
Code: Select all
$db = mysql_connect("localhost", "root");
mysql_select_db("library",$db);Code: Select all
//db_connect.php
<?php
$db_user = 'localhost
$db_pass = 'root
$db_host = 'localhost'; //Usually "localhost"
$db_name = 'library';
$con= @mysql_connect("$db_host","$db_user","$db_pass")
or die ("Cannot connect to MySQL.");
$db = @mysql_select_db("$db_name",$con)
or die ("Cannot select the $db_name database. Please check your details in the database connection file and try again");
?>Code: Select all
Cannot connect to MySQL.Code: Select all
or die ("Cannot connect to MySQL.");
or die ("Cannot select the $db_name database. Please check your details in the database connection file and try again");Code: Select all
Parse error: parse error, unexpected T_VARIABLE in c:\program files\apache group\apache\htdocs\db_connect.php on line 10This is how i always get my Mysql DB up and running...do you see any problem here ? or do you want to suggest a better way that is more widely used?
Code: Select all
i put my "mysql" in C:\
Then I go to C:\mysql\cd bin and click on mysqladmin icon..it asks for a username and password..After i finished providing the necessary information it comes to stay on my status bar and shows green light when the Db server is on and red when it is off....Am i doing anything wrong by starting MySql server like that?Can anybody sheds some light?