⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysql-实用技巧-20.htm

📁 微软数据库开发梦工场多媒体教学-My sql篇.rar
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#000000" text="#FFFFFF">
<p>(9) string mysql_error(int [link_id]); </p>
<p>   对于给定的连接,返回含有最近返回状态的与MySQL相关的函数的错误消息字符串。空值意味着未出现错误。 </p>
<p>&lt;?php </p>
<p>$link=mysql_pconnect(&quot;localhost&quot;,&quot;sunsoft&quot;,&quot;suixiang&quot;) 
  <br>
  or die(&quot;Could not connect&quot;); </p>
<p>print(&quot;Connected successfully&quot;); </p>
<p>$query=&quot;SELECT * FROM president&quot;; </p>
<p>$result=mysql_query($query) or die(&quot;query failed,error message=&quot;.mysql_error()); 
</p>
<p><br>
  ?&gt; </p>
<p>(10)array mysql_fetch_array(int result, int [result_typ]); </p>
<p>   本函式用来将查询结果 result 拆到阵列变数中。若 result 没有资料,则传回 false 值。而本函式可以说是 mysql_fetch_row() 
  的加强函式,除可以将传回列及数字索引放入阵列之外,还可以将文字索引放入阵列中。若是好几个传回栏位都是相同的文字名称,则最后一个置入的栏位有效,解决方法是使用数字索引或者为这些同名的栏位 
  (column) 取别名 (alias)。值得注意的是使用本函式的处理速度其实不会比mysql_fetch_row() 函式慢,要用哪个函式还是看使用的需求决定。参数 
  result_typ 是一个常数值,有以下几种常数 MYSQL_ASSOC、MYSQL_NUM 与 MYSQL_BOTH。 </p>
<p><br>
  使用范例 </p>
<p>&lt;?php </p>
<p>$link=mysql_pconnect(&quot;localhost&quot;,&quot;sunsoft&quot;,&quot;suixiang&quot;) 
  <br>
  or die(&quot;Could not connect&quot;); </p>
<p>mysql_select_db(&quot;stamp_db&quot;) or die(&quot;Could not select database&quot;); 
</p>
<p><br>
  $query=&quot;SELECT last_name,first_name FROM president&quot;; </p>
<p>$result=mysql_query($query) or die(&quot;Query failed&quot;); </p>
<p>while($row=mysql_fetch_array($result)) </p>
<p>{ </p>
<p>printf(&quot;%s %s&lt;BR&gt;</p>
<p>&quot;,$row[0],$row[1]); </p>
<p>printf(&quot;%s %s&lt;BR&gt;</p>
<p>&quot;,$row[&quot;last_name&quot;],$row[&quot;first_name&quot;]); </p>
<p>} </p>
<p>mysql_free_result($result); </p>
<p>?&gt; </p>
<p> <br>
</p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -