MySQL function library: mysql_query

Source: Internet
Author: User
Keywords mysql_query mysql function Library php Chinese function manual
Tags aliyun function function library html http link mysql mysql function library

Mysql_query

mysql_query---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Send out MySQL Query

Syntax: int mysql_query (string query [, int link_identifier])

Description:

mysql_query () sends out queries to the current database on the server, and if Link_identifier is not specified, it is assumed to be the last open link, and if there is no open link, this function will try to mysql_connect () Create a link without any parameters and use it.

This query string should not be preceded by a semicolon (;).

Mysql_query () returns True (not 0) or false to indicate whether the query succeeded, returns a value of true, indicating that the query is legitimate and can be executed by the server, and does not indicate or return the number of affected columns.

The following query is a syntax-structured error, so mysql_query () fails and returns FALSE.

Example:

<?php

$result = mysql_query ("SELECT * WHERE 1=1") or Die ("Invalid query");

?>

If My_col is not a field in the table MY_TB1, the following query is semantically incorrect, so mysql_query () fails and returns FALSE.

Example:

<?php

$result = mysql_query ("SELECT my_col from My_tbl") or Die ("Invalid query");

?>

If your query string does not have permission to access the table, mysql_query () also fails and returns FALSE.

Once the query is successful, you can call Mysql_affected_rows () to find out delete,insert,replace, or the number of columns affected by the update syntax, and the SELECT Syntax mysql_query () returns a new result identifier, you can pass it to mysql_result (). When the query is finished, you can call Mysql_free_result () to release resources (Resource).

Reference: Mysql_affected_rows () mysql_db_query () mysql_free_result () mysql_result ()

mysql_select_db () mysql_connect ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.