设为首页 加入收藏

TOP

mysql_query返回值
2011-06-12 21:22:51 来源: 作者: 【 】 浏览:47次 评论:0

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() 函数创建一个新数据库

<?php
$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()函数最后一次打开的连接

您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇mysql数据库程序优化方法 下一篇MySQL存储过程实例教程

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位