dsgdhtr_43654 2013-12-18 10:27 采纳率: 100%
浏览 10

mysql_num_rows()期望参数1是资源,给定[duplicate]的数组

Hi I have been struggling with this query for a while now

I need to get the number of rows inserted into my database table, but I keep getting this error I can't seem to get rid of.

$result3=mysql_query("INSERT INTO dest_table.create_info SELECT * from 
Profusion.source_cdr");
$num_rows = array($result3);
$progress=mysql_num_rows($num_rows);
echo $progress;

The error I get is

mysql_num_rows() expects parameter 1 to be resource, array given

It will be highly appreciated if I get this resolved

</div>
  • 写回答

2条回答 默认 最新

  • dqdt45183 2013-12-18 10:29
    关注

    You have to pass the resource not the array.

    $result3=mysql_query("INSERT INTO dest_table.create_info SELECT * from 
    Profusion.source_cdr");
    $progress=mysql_num_rows($result3);
    echo $progress;
    

    But since you are using INSERT you should read the manual and use mysql_affected_rows() because mysql_num_rows() only works with SELECT and SHOW.

    http://www.php.net/manual/de/function.mysql-affected-rows.php

    $result3=mysql_query("INSERT INTO dest_table.create_info SELECT * from 
    Profusion.source_cdr");
    $progress=mysql_affected_rows();
    echo $progress;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100