前者要在执行时需要指定一个数据库,而后者使用前要用mysql_select_db来指定数据库,两者在功能上是相同的。

解决方案 »

  1.   

    他们说得差不多,不过建议你用mysql_select_db()而不用mysql_db_query()
    想了解更多的话,你可以看一下帮助
      

  2.   

    我觉得提供 mysql_db_query就是为了操纵关联数据库方便,如果操纵多个数据库你每次用mysql_query前都要先 mysql_select_db(数据库名), mysql_db_query不过是把前面的两句整合成一句了,如果只是操纵一个数据库我觉得没有必要用 mysql_db_query每次都要加上数据库
      

  3.   

    mysql_db_query Description:
    resource mysql_db_query ( string database, string query [, resource link_identifier])
    mysql_db_query() selects a database and executes a query on it. If the optional link identifier isn't specified, the function will try to find an open link to the MySQL server and if no such link is found it'll try to create one as if mysql_connect() was called with no arguments.
    mysql_query Description:
    resource mysql_query ( string query [, resource link_identifier [, int result_mode]])
    mysql_query() sends a query to the currently active database on the server that's associated with the specified link identifier. 
      

  4.   

    我同意 fhy1977227fhy(fhy)说法
      

  5.   

    mysql_connect($hostname, $user, $password);
    mysql_select_db("db_name");               
    $query="select password from load where username='$test_username'";
    $result=mysql_query($query);
    $password_row=mysql_fetch_array($result);
    $db_password=$password_row[0];