msql_query

Send mSQL query (PHP 3, PHP 4, PHP 5)
resource msql_query ( string query [, resource link_identifier] )

msql_query() sends a query to the currently active database on the server that's associated with the specified link identifier.

参数

query

The SQL query.

link_identifier

mSQL 的连接标识符。如果没有指定,默认使用最后被 msql_connect() 打开的连接。如果没有找到该连接,函数会尝试通过调用 msql_connect() 建立连接并使用它。

返回值

Returns a positive mSQL query identifier on success, or FALSE on error.

范例

例 1175. msql_query() example

<?php
$link
= msql_connect("dbserver")
  or die(
"unable to connect to msql server: " . msql_error());
msql_select_db("db", $link)
  or die(
"unable to select database 'db': " . msql_error());

$result = msql_query("SELECT * FROM table WHERE id=1", $link);
if (!
$result) {
  die(
"query failed: " . msql_error());
}

while (
$row = msql_fetch_array($result)) {
   echo
$row["id"];
}
?>