i have trying to test some mysql+php example on my machine
however, i just make this program runnign properly
within this post, there are the code for sql, db_connect.php
and in my databse , i have user 'tom' , pass 'tom', that has been grant all privileage.
i want to know why i can't see 'state 2' and 'state 3' ,, i only can see 'state 1'
thx
Tom
user table
--------------------------
----------
----------
------
mysql> select host,user,password from user;
+-----------+------+------
----------
--+
| host | user | password |
+-----------+------+------
----------
--+
| localhost | root | 67457e226a1a15bd |
| % | root | 67457e226a1a15bd |
| localhost | | |
| % | | |
| % | test | 378b243e220ca493 |
| localhost | tom | 675bd1463e544441 |
| % | tom | 675bd1463e544441 |
+-----------+------+------
----------
--+
7 rows in set (0.00 sec)
sql file
--------------------------
----------
----------
-
drop database if exists guestbook;
create database guestbook;
use guestbook;
drop table if exists guestbook
;
create table guestbook
(
name varchar(40) null,
location varchar(40) null,
email varchar(40) null,
url varchar(40) null,
comments text null
)
;
grant delete, insert, select, update on guestbook to 'tom'@'localhost' identified by 'tom';
dbconnect.php
--------------------------
-----
<?php
print " state 1";
$link = mysql_connect('localhost',
'tom','tom
');
print " state 2";
if($link) {
print "state 3";
//die("<h3>could not connect to MySQL</h3>\n");
}
mysql_close($link);
mysql_select_db('guestbook
')or die("<h3>could not select database 'guestbook'</h3>\n");
?>
Start Free Trial