How to view the SQL statements executed by Android back to Php-server (based on Discuz interface) parameters

Source: Internet
Author: User
Tags sql error
The project configuration is described as follows:
Server-side: discuz, debugging a server-side interface to Android (to receive requests sent from Android)
Client: Android4.4

The problem flow is described as follows:
After posting on the forum, the Android side uses the HttpPost package parameter to send the relevant URL to the PHP side via the httpclient, and performs the relevant SQL operation on the PHP side by mysql_query returning True or false to the Android side.

The problem is described as follows:
Now on the Android side get post returned result is {"result": "Post Failed"}, (ˇ?ˇ) thought might be PHP side in the execution of SQL operation error, want to see the PHP side executed SQL statement. Because my PHP interface is based on Discuz, if the interface is deployed through Zend Studio to Apache Htdocs, I have tried, did not deploy successfully, unable to receive the parameters sent by the Android side

Would like to ask you,
1) Is it possible to deploy this interface to Apache to receive data from Android (win7,apache,mysql,php5.25,zend Studio 10.0)
2) If not, how to debug the Android side to send to the PHP server parameters; Now I want to look at the SQL statements that are executed after being passed back to the PHP server.

Thank you all first.


Reply to discussion (solution)

This problem happened to me too, 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 the $errormsg into a 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);//The back is not copied ...}

The disadvantage is that all discuz SQL errors will be recorded in, of course, the general discuz of the SQL error is still very small

First of all thank jam00 for the answer, but I this forum is discuzX2 version, I made in \source\class\class_error.php you said the corresponding changes:

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);

After running Android post, there is no log.txt this file found in the Android folder.
I would like to add that my post request is that Android is sent directly to the application interface (which can be accessed directly as a Level 2 directory), then the MySQL database is processed via SQL and then returned to Android for page rendering; there is no communication with the original Discuz X2. Therefore, setting the error log in the original Discuz x project does not capture the error of this independent interface. So I thought about debugging the interface in Zend studio10.0 and getting the SQL statement.
Anyway, thanks to Jam00 's enthusiastic answer!

If you want to combine with Discuz's data and reduce development time, it is recommended that you use Discuz's existing DB classes and methods
I don't know where Zend is. sql, but execute SQL error, you can use Mysql_error () to get error information, with file_put_contents output to a txt inside

Light up the relevant code for your interface.
No code how to solve the problem ...

This need to see your interface, can you manually debug?
If you can, you just need to care about the parameters of the transfer

A system like yours that is packaged with data needs to be debugged by separating the client from the server.

Thank you all, especially thank you for the first Help jam00, the problem has been solved. By looking at the error of mysql_error, a field type of Forum_post was finally modified.

  • Related Article

    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.