flyclassic22
Technical User
i'm totally new to php and mysql, i've use ASP before though with microsoft access db, odbc connection. I'ved tried installing the php windows installer to my winxp(with IIS) and then mysql server 4.3.1 everything installed
saw an example from the web, and decided to try out..
myphpfile.php
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));
printf("Address: %s<br>\n", mysql_result($result,0,"address"));
printf("Position: %s<br>\n", mysql_result($result,0,"position"));
?>
</body>
</html>
in mysql, i've created the following database
mydb
CREATE TABLE employees ( id tinyint(4) NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id));INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager');
INSERT INTO employees VALUES (2,'John','Roberts','45 There St , Townville','Telephonist');
INSERT INTO employees VALUES (3,'Brad','Johnson','1/34 Nowhere Blvd, Snowston','Doorman');
however when i tried accessing my i've got the following message.
Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) .
It seems like it cannot access mysql server, i don't know how, stuck from there, i've trying to read the password hashing in the documentation, but not quite understand.
Perhaps anyone can help?
saw an example from the web, and decided to try out..
myphpfile.php
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));
printf("Address: %s<br>\n", mysql_result($result,0,"address"));
printf("Position: %s<br>\n", mysql_result($result,0,"position"));
?>
</body>
</html>
in mysql, i've created the following database
mydb
CREATE TABLE employees ( id tinyint(4) NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id));INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager');
INSERT INTO employees VALUES (2,'John','Roberts','45 There St , Townville','Telephonist');
INSERT INTO employees VALUES (3,'Brad','Johnson','1/34 Nowhere Blvd, Snowston','Doorman');
however when i tried accessing my i've got the following message.
Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) .
It seems like it cannot access mysql server, i don't know how, stuck from there, i've trying to read the password hashing in the documentation, but not quite understand.
Perhaps anyone can help?