How to view the SQL statement that android executes after returning parameters to the php-server (relying on the discuz interface)

Source: Internet
Author: User
Tags php server
How to view the project configuration of the SQL statement that android executes after returning the parameter to php-server (relying on the discuz interface:
Server: discuz, debugging the server interface connecting to android (used to receive requests sent from android)
Client: Android4.4

The problem process is described as follows:
After the android client posts a post on the forum, it uses httppost to encapsulate parameters and sends the relevant url to the php client through httpclient; execute related SQL operations on the php client, and return true or false to the android client through mysql_query.

The problem is described as follows:
Now the result returned by the post on android is {"result": "post failed"}, (response? An error may occur when the php side executes the SQL operation. you want to view the SQL statement executed by the php side. Because my php interface relies on discuz, if I separately deploy this interface to Apache's htdocs through zend studio, I have tried and cannot receive parameters sent by android.

For more information,
1) Is it possible to deploy this interface to apache to receive android data (win7, apache, mysql, php5.25, zend studio 10.0)
2) If not, how can I debug the parameters that android sends to the php Server? now I want to check the SQL statements that are executed after being passed back to the php server.

Thank you!


Reply to discussion (solution)

This problem happened to me. the solution is as follows:
Find \ source \ class \ discuz \ discuz_error.php and open
Search: show_error ($ type, $ errormsg, $ phpmsg = '', $ typemsg = '')
Under the show_error function, use the file_put_contents function to print $ errormsg to a txt file.

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); // The following content will not be copied ...}

The disadvantage is that all SQL errors of discuz are recorded. of course, SQL errors reported by discuz are rare.

First of all, I would like to thank jam00 for your answers, but I am using discuzX2 in this forum. I made the following changes in \ 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);

The log.txt file was not found in the androidfolder after the androiddevelopment folder was run.
I would like to add: my post request is sent directly to the application interface by android (this interface can be directly accessed as a level 2 directory), and then the mysql database is processed through SQL, then return to android for page rendering; no communication with the original discuz X2. Therefore, the error log setting in the original discuz X project cannot capture the error of this independent interface. Therefore, you must debug the interface in zend studio10.0 to obtain the SQL statement.
Thank you for your answers!

If you want to perfectly combine discuz data and reduce development time, we recommend that you use the existing DB classes and methods of discuz.
I don't know where zend has processed the SQL, but you can use mysql_error () to get the error message and output it to a txt file using file_put_contents.

Expose the code related to your interface.
No code to solve the problem...

This depends on your interface. can I manually debug it separately?
If yes, you only need to care about the transmitted parameters

If you package your data, you need to debug the client and server separately.

Thank you, especially for the help of jam00. The problem has been solved. Check the error message of mysql_error and modify the field type of forum_post.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.