duanhuang1967 2013-04-04 11:20
浏览 83
已采纳

mysql_fetch_assoc():提供的参数不是有效的MySQL [重复]

I have created an android application,by using this function in php i am creating a
a new user in database mysql.

function signUp($sName, $sMobile, $sAddress, $sEmail, $sPwd)
    {
    $sql = "insert into customers (name,mobile,address,email,pwd) values ('$sName','$sMobile','$sAddress','$sEmail','$sPwd')";
    $run = $this->query($sql);
    if ($this->result <= 0) {
        return false;
    } else {
        return $this->json('DATA');
    }
}

With the below function i am querying in database and returning the response in json format

function query($sql){
$query = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($query)){
$this->result[] = $row;
}
return $this;
}

but the response i am getting has an error i tried surpessing the warnings by using

@mysql_fetch_assoc($query)

It gave a proper response in browser but android gets null as response

Error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in

Warning: Cannot modify header information - headers already sent by (output started at

Help required New to PHP. Thanks in advance

</div>
  • 写回答

3条回答 默认 最新

  • douqiao5314 2013-04-04 11:45
    关注

    You can't get result by

    Insert Query
    but you can get id of current inserted user by
    mysql_insert_id()
    and then you can use "Select Query" against that id.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题