Home > PHP > Function > MySQL > mysql_query()

mysql_query()

mysql_query - Send a MySQL query

Syntax

resource mysql_query (string $query, resource $link_identifier)

Arguments

  • query - A SQL query The query string should not end with a semicolon. Data inside the query should be properly escaped.
  • link_identifier - The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.

Description

mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

Version

PHP 4, 5

Return value

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.