doutan3371 2015-04-21 21:22
浏览 50
已采纳

too long

Tying myself in knots a little bit with cURL. Using codeigniter for my framework and downloaded the CURL lib from getsparks.org/packages/curl . I have this URL http://localhost:8984/rest?run=loc.xq&$a=York so this is a Rest for BaseX that I pass in a city (like York) and it shows me a carpark, This works in my browser. So what i wanted to do is have a user type the name into a form and pass that to basex and display the results. I have me view, controller set up, and this is currently the code I have in the controller

 $this->load->library('curl');
 $url = "http://localhost:8984/rest?run=loc.xq&$a=";
 $datai = array($this->input->POST('carpark_location'));
 $results = $this->curl->simple_get($url,$datai);

so this to me looks right, but its not, comes back with an error,

Message: Undefined variable: a

which I am guessing its picking $a out of the text as a variable, how would I make it ignore that? not sure if just that will solve my issue but printing out the $url and $datai looks like below?

 http://localhost:8984/rest?run=loc.xq&=Array ( [0] => York ) 

what am I missing?

  • 写回答

1条回答 默认 最新

  • dongqianwei6664 2015-04-21 21:37
    关注

    Try this instead:

    $url = 'http://localhost:8984/rest?run=loc.xq&$a='

    Because it is inside single quotes instead of double quotes, PHP should treat $a as if it is part of the string instead of as a variable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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