Loading

PHP与数据库交互相关

连接数据库

$dbcnx = @mysql_connect ( "localhost", "root", "1234" );
if (! $dbcnx) {
echo ("Unable to connect to the " . "database server at this time.");
exit ();
}

if (! @mysql_select_db ( "pms" )) {
echo ("Unable to locate the joke " . "database at this time.");
exit ();
}

 

设定字符

mysql_query ( "SET NAMES 'GB2312'" );

 

查询

$q=mysql_query("select `Right` from employee where username ='".$username."'");

 

赋值

$right=mysql_fetch_row($q)
posted @ 2012-09-14 09:17  魍魉_198x  阅读(250)  评论(0编辑  收藏  举报