Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 如何查看android回传给php-server(依托discuz的接口)参数后执行的sql语句

如何查看android回传给php-server(依托discuz的接口)参数后执行的sql语句

Jun 23, 2016 pm 01:51 PM
android sql parameter interface Check

项目配置描述如下:
服务器端: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);//后面的就不复制了...}
Copy after login

缺点就是,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);
Copy after login

运行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的一个字段类型。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:23 PM

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

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Sep 12, 2024 pm 09:21 PM

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

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:22 PM

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

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Sep 27, 2024 am 06:23 AM

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

Oppo Find X8 design looks like a cross between Apple iPhone 16 Pro and OnePlus Open in early images Oppo Find X8 design looks like a cross between Apple iPhone 16 Pro and OnePlus Open in early images Sep 28, 2024 am 06:04 AM

Historically, Oppo has refreshed its flagship 'Find X' series in late winter or early spring, save for the original Find X that it announced in June 2018. To that end, the Find X7 and Find X7 Ultra are barely more than six months old at this point. H

Galaxy A16 5G: Leak reveals future release aimed at freshening up Samsung\'s cheapest Galaxy A series model Galaxy A16 5G: Leak reveals future release aimed at freshening up Samsung\'s cheapest Galaxy A series model Sep 12, 2024 pm 12:20 PM

It seems that the launch of a new entry-level Galaxy A series smartphone could be in the offing. Although Samsung has not officially announced anything just yet, Android Headlines has already published render images of what it claims is a Galaxy A15

Xiaomi Redmi Note 14, Redmi Note 14 Pro and Redmi Note 14 Pro Plus to shake up mid-range smartphone market with Gorilla Glass Victus 2 and IP69 certification Xiaomi Redmi Note 14, Redmi Note 14 Pro and Redmi Note 14 Pro Plus to shake up mid-range smartphone market with Gorilla Glass Victus 2 and IP69 certification Sep 24, 2024 pm 12:15 PM

Xiaomi has just announced the release date for its next Redmi Note smartphones. As expected, these are set to arrive as three Redmi Note 14 series handsets. More specifically, the company intends to release the Redmi Note 14, Redmi Note 14 Pro and Re

Lenovo reveals new color option for the 2024 Legion Y700 gaming tablet Lenovo reveals new color option for the 2024 Legion Y700 gaming tablet Sep 29, 2024 am 06:05 AM

Lenovo is gearing up to launch the 2024 Legion Y700 on September 29 in China. This new Android gaming tablet will be going against the RedMagic Nova, and the company has already confirmed almost all the specs of the device. Now, hours before the full

See all articles