最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mysql_query返回值
时间:2009-08-29 编辑:简简单单 来源:一聚教程网
mysql_query返回值
php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT * FROM Person";
mysql_query($sql,$con);
// 一些代码
mysql_close($con);
?>例子 2
通过 mysql_query() 函数创建一个新数据库:
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql = "CREATE DATABASE my_db";
if (mysql_query($sql,$con))
{
echo "Database my_db created";
}
else
{
echo "Error creating database: " . mysql_error();
}
?>
The mysql_query() function executes a query on a MySQL database.
mysql_query()函数的作用是:发送一条 MySQL 查询。
This function returns the query handle for SELECT queries, TRUE/FALSE for other
queries, or FALSE on failure.
如果函数执行成功,它将返回True,并通过SELECT查询语句返回查询结果;如果函数执行
失败,将返回False。
Syntax
语法
mysql_query(query,connection)
Parameter参数 Description描述
query Required. Specifies the SQL query to send (should not end with a
semicolon)
必要参数。指定需要发送的SQL查询语句(不可以以分号“;”结束)
connection Optional. Specifies the MySQL connection. If not specified, the last
connection opened by mysql_connect() or mysql_pconnect() is used.
可选参数。指定MySQL连接。如果不指定该参数,那将默认使用通过mysql_connect()函数
或mysql_pconnect()函数最后一次打开的连接
-
上一个: MySQL存储过程实例教程
-
下一个: mysql数据库程序优化方法
相关文章
- MySQL登录、访问及退出操作解析 10-18
- sql语句 update字段null不能用is null问题解析 09-28
- SQL Server ISNULL 不生效原因及解决分析 09-28
- 关于if exists的用法及说明分析 09-28
- Access数据库日常维护方法 09-28
- Oracle 删除大量表记录操作介绍 09-27