doushan1850 2013-03-05 04:33
浏览 40

从PHP / SQLite中的Query返回字符串

I am attempting to create a cookie with the return string of this query:

$id = $database -> query("SELECT id FROM accounts WHERE username = '$username' AND password = '$password'");

However, it is returning an object rather than a string. I am trying to return the "id" of the row. How do I do this?

  • 写回答

3条回答 默认 最新

  • drcmue4619 2013-03-05 04:40
    关注

    You need to extract the array object so that you can access the id string!

    $id = $this->db->get()->row_array()->('id');
    

    then you can use $id and set it in a cookie:

    setcookie("session", "$id", time()+3600);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo