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 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献