for 多输出了一条语句解决思路

WBOY
Release: 2016-06-13 11:49:26
Original
947 people have browsed it

for 多输出了一条语句

本帖最后由 hilives 于 2014-02-27 17:50:43 编辑 使用for循环输出一条语句,但是输出了两条一样的语句,没看出问题在哪,求指点
<br /> $rows="1" ;//取得查詢結果的記錄筆數<br /><br /><br />       for ($i=1;$i<=$rows;$i++) {<br />	<br />	  <br />  $str = <<<EOT<br />      猪<br />	  <br />EOT;<br /><br /><br />$str=addslashes($str);  <br /> //addslashes这个函数会对字符串进行处理,即对   '   或者  "  的,用    \'    和   \''  替换<br /> <br /><br /><br /><br />$sqlk=" UPDATE zhixing SET shuju= concat(shuju,'$str')   WHERE time = '$jintian'"; //执行更新语句 <br />$resultk = mysql_query($sqlk); //执行语句 <br /><br />if (!mysql_query($sqlk,$con))<br />  {<br />  die('Error: ' . mysql_error());<br />  }<br /><br />	 <br />	<br />	   }<br /><br /><br /><br />
Copy after login


记录到数据库里的结果是两个猪,shuju这个字段在执行前是空的
------解决方案--------------------
$resultk = mysql_query($sqlk); //执行语句 
 
if (!mysql_query($sqlk,$con))
  {
  die('Error: ' . mysql_error());
  }

两次mysql_query 不是两次了吗?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!