如何查看android回传给php-server(依托discuz的接口)参数后执行的sql语句
项目配置描述如下:
服务器端:discuz,正在调试连接android的服务器端接口(用来接收android端发送过来的请求)
客户端:Android4.4
问题流程描述如下:
android端在论坛发帖后,使用httppost封装参数,通过httpclient发送到php端的相关url;在php端执行相关的sql操作,通过mysql_query返回true或者false给android端。
问题描述如下:
现在在android端得到发帖返回的结果是{"result":"post failed"} ,(ˇ?ˇ) 想到可能是php端在执行sql操作时发生了错误,想查看php端执行的sql语句。由于我的php接口是依托于discuz的,如果单独将该接口通过zend studio部署到Apache的htdocs,我试过,没有部署成功,无法接收android端发送的参数
想咨询下大家,
1)有没有可能将此接口部署到apache以接收android端的数据(win7,apache,mysql,php5.25,zend studio 10.0)
2)如果没有,怎么调试android端传送给php服务端的参数;现在主要想查看回传给php服务端后,执行的sql语句。
先谢谢大家了
回复讨论(解决方案)
这个问题刚好我也遇到了,解决办法如下
找到:\source\class\discuz\discuz_error.php,并打开
搜索:show_error($type, $errormsg, $phpmsg = '', $typemsg = '')
在show_error函数下面,用file_put_contents函数将$errormsg打印到一个txt里面
public static function show_error($type, $errormsg, $phpmsg = '', $typemsg = '') { global $_G;file_put_contents(DISCUZ_ROOT.'./appapi/log.txt',$errormsg.PHP_EOL,FILE_APPEND); ob_end_clean(); $gzip = getglobal('gzipcompress'); ob_start($gzip ? 'ob_gzhandler' : null);//后面的就不复制了...}
缺点就是,discuz的所有sql错误都会记录在里面,当然一般discuz报的sql错误还是很少的
首先感谢jam00的回答,但我这个论坛是discuzX2的版本,我在 \source\class\class_error.php中进行了您说的相应修改:
function show_error($type, $errormsg, $phpmsg = '') { global $_G; file_put_contents('http://192.168.1.101/bbs/android/log.txt',$errormsg.PHP_EOL,FILE_APPEND); //file_put_contents(DISCUZ_ROOT.'./android/log.txt',$errormsg.PHP_EOL,FILE_APPEND); ob_end_clean(); $gzip = getglobal('gzipcompress'); ob_start($gzip ? 'ob_gzhandler' : null);
运行android发帖后,没有在android文件夹中发现log.txt这个文件。
我想补充一点:我的post请求是android直接发给应用接口(该接口可以作为2级目录直接访问)的,然后通过sql处理mysql数据库,再返回给android进行页面呈现;没有和原有的discuz X2进行通信。所以在原有的discuz X项目中设置错误日志估计不能捕捉到这种独立接口的错误。因此才想到要在zend studio10.0中调试接口,获取sql语句。
不管怎样,还是要谢谢jam00的热心解答!
若你想和discuz的数据完美结合,并减少开发时间的话,建议你还是用discuz已有的DB类和方法
我不知道zend 在哪里处理了sql,不过执行sql错误,你可以用mysql_error()获取错误信息,用file_put_contents输出到一个txt里面
把你接口的相关代码亮出来。
没代码怎么解决问题。。。
这个需要看你的接口了,能不能手工单独调试?
如果能,你只需要关心传送的参数
像你这样对发挥数据做了包装的系统,需要对客户端和服务端分开来调试
谢谢大家,尤其谢谢最先提供帮助的jam00,问题已经解决了。通过查看mysql_error,的报错,最后修改了forum_post的一个字段类型。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

Alongside announcing two new smartphones, TCL has also announced a new Android tablet called the NXTPAPER 14, and its massive screen size is one of its selling points. The NXTPAPER 14 features version 3.0 of TCL's signature brand of matte LCD panels

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

Motorola has released countless devices this year, although only two of them are foldables. For context, while most of the world has received the pair as the Razr 50 and Razr 50 Ultra, Motorola offers them in North America as the Razr 2024 and Razr 2

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of
