In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use mysql_query () in php. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The php mysql_query () function is used to execute the sql statement. When querying, updating, and adding data, you can write the sql statement, and then use the mysql_query () function to execute the sql statement to operate on the specified database; syntax "mysql_query ($sql [, $con])".
Operating environment of this tutorial: windows7 system, PHP5 version, DELL G3 computer
The php mysql_query function is used to execute sql statements. For example, when querying, updating, and adding data, we usually write sql statements, and then use mysql_query to perform the operations required by sql.
Let's take a look at an example:
The steps for php to manipulate the database can be divided into the following steps:
1. Connect to the database server
2. Select the database to be operated
3. Execute the SQL statement
4. The result set obtained by processing the SQL statement
5. Shut down or disconnect the database server
The third step in executing the sql statement requires the use of the mysql_query () function, as shown in the above example:
$query = "drop table if exists mytable"; $result = mysql_query ($query)
This SQL statement executes the command to delete the table mytable. Returns true if the execution is successful, false otherwise. But the mysql_query function does not necessarily just return true and false.
The mysql_query function returns a resource identifier for SELECT, SHOW, EXPLAIN, or DESCRIBE statements, or FALSE if the query executes incorrectly. For other types of SQL statements, mysql_query () returns TRUE on success and FALSE on error.
Note:
Mysql_query () has been deprecated since PHP 5.5.0 and removed since PHP 7.0.0. It should be replaced with a MySQLi or PDO_MySQL extension. To replace this function are:
Mysqli_query ()
PDO::query ()
This is the end of the article on "how to use mysql_query () in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.