0

こんにちは、PHP Web サービスを介して Android と MySQL を使用していますが、logcat に次のエラーが表示されます。

06-08 07:04:37.939: I/Parsing(309): [    
06-08 07:04:37.939: I/Parsing(309): <b>Notice</b>:  Undefined variable: temp_result in <b>C:\xampp\htdocs\bpn_web_service\warkah.php</b> on line <b>46</b>    
06-08 07:04:37.939: I/Parsing(309):     
06-08 07:04:37.939: I/Parsing(309): <b>Warning</b>:  array_push() expects parameter 1 to be array, null given in <b>C:\xampp\htdocs\bpn_web_service\warkah.php</b> on line <b>57</b>    
06-08 07:04:37.939: I/Parsing(309):     
06-08 07:04:37.939: I/Parsing(309): <b>Warning</b>:  array_push() expects parameter 1 to be array, null given in <b>C:\xampp\htdocs\bpn_web_service\warkah.php</b> on line <b>57</b>    
06-08 07:04:37.939: I/Parsing(309): {"result":null,"code":1,"message":"Success"}
06-08 07:04:37.939: I/Parsing(309): ]
06-08 07:04:37.960: E/JSON Parser(309): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject    
06-08 07:04:37.960: E/JSON Parser(309): <b>Notice</b>:  Undefined variable: temp_result in <b>C:\xampp\htdocs\bpn_web_service\warkah.php</b> on line <b>46</b>    
06-08 07:04:37.960: E/JSON Parser(309):     
06-08 07:04:37.960: E/JSON Parser(309): <b>Warning</b>:  array_push() expects parameter 1 to be array, null given in <b>C:\xampp\htdocs\bpn_web_service\warkah.php</b> on line <b>57</b>    
06-08 07:04:37.960: E/JSON Parser(309):     
06-08 07:04:37.960: E/JSON Parser(309): <b>Warning</b>:  array_push() expects parameter 1 to be array, null given in <b>C:\xampp\htdocs\bpn_web_service\warkah.php</b> on line <b>57</b>    
06-08 07:04:37.960: E/JSON Parser(309): {"result":null,"code":1,"message":"Success"}
06-08 07:04:37.960: W/dalvikvm(309): threadid=8: thread exiting with uncaught exception (group=0x4001d800)
06-08 07:04:38.019: E/AndroidRuntime(309): FATAL EXCEPTION: AsyncTask #1
06-08 07:04:38.019: E/AndroidRuntime(309): java.lang.RuntimeException: An error occured while executing doInBackground()
06-08 07:04:38.019: E/AndroidRuntime(309):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.lang.Thread.run(Thread.java:1096)
06-08 07:04:38.019: E/AndroidRuntime(309): Caused by: java.lang.NullPointerException
06-08 07:04:38.019: E/AndroidRuntime(309):  at com.radit.bpnmobile.warkah$search_warkah.doInBackground(warkah.java:95)
06-08 07:04:38.019: E/AndroidRuntime(309):  at com.radit.bpnmobile.warkah$search_warkah.doInBackground(warkah.java:1)
06-08 07:04:38.019: E/AndroidRuntime(309):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-08 07:04:38.019: E/AndroidRuntime(309):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-08 07:04:38.019: E/AndroidRuntime(309):  ... 4 more
06-08 07:04:40.179: E/WindowManager(309): Activity com.radit.bpnmobile.warkah has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43e6ea40 that was originally added here
06-08 07:04:40.179: E/WindowManager(309): android.view.WindowLeaked: Activity com.radit.bpnmobile.warkah has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43e6ea40 that was originally added here
06-08 07:04:40.179: E/WindowManager(309):   at android.view.ViewRoot.<init>(ViewRoot.java:247)
06-08 07:04:40.179: E/WindowManager(309):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
06-08 07:04:40.179: E/WindowManager(309):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-08 07:04:40.179: E/WindowManager(309):   at android.view.Window$LocalWindowManager.addView(Window.java:424)
06-08 07:04:40.179: E/WindowManager(309):   at android.app.Dialog.show(Dialog.java:241)
06-08 07:04:40.179: E/WindowManager(309):   at com.radit.bpnmobile.warkah$search_warkah.onPreExecute(warkah.java:78)
06-08 07:04:40.179: E/WindowManager(309):   at android.os.AsyncTask.execute(AsyncTask.java:391)
06-08 07:04:40.179: E/WindowManager(309):   at com.radit.bpnmobile.warkah$1.onClick(warkah.java:64)
06-08 07:04:40.179: E/WindowManager(309):   at android.view.View.performClick(View.java:2408)
06-08 07:04:40.179: E/WindowManager(309):   at android.view.View$PerformClick.run(View.java:8816)
06-08 07:04:40.179: E/WindowManager(309):   at android.os.Handler.handleCallback(Handler.java:587)
06-08 07:04:40.179: E/WindowManager(309):   at android.os.Handler.dispatchMessage(Handler.java:92)
06-08 07:04:40.179: E/WindowManager(309):   at android.os.Looper.loop(Looper.java:123)
06-08 07:04:40.179: E/WindowManager(309):   at android.app.ActivityThread.main(ActivityThread.java:4627)
06-08 07:04:40.179: E/WindowManager(309):   at java.lang.reflect.Method.invokeNative(Native Method)
06-08 07:04:40.179: E/WindowManager(309):   at java.lang.reflect.Method.invoke(Method.java:521)
06-08 07:04:40.179: E/WindowManager(309):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-08 07:04:40.179: E/WindowManager(309):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-08 07:04:40.179: E/WindowManager(309):   at dalvik.system.NativeStart.main(Native Method)

以下は、ステートメントが57行目のエラー行の私のコードですarray_push($response["result"], $temp_result)

if(mysql_num_rows($query) > 0)
        {
            $reponse["result"] = array();

            while($row = mysql_fetch_array($query))
            {
                $temp_result[] = array();
                $temp_result["no_warkah"] = $row["no_warkah"];
                $temp_result["tahun"] = $row["tahun"];
                $temp_result["desa"] = $row["desa"];
                $temp_result["kecamatan"] = $row["kecamatan"];
                $temp_result["rak"] = $row["rak"];
                $temp_result["blok"] = $row["blok"];
                array_push($response["result"], $temp_result);
            }
            $response["code"] = 1;
            $response["message"] = "Success";
            echo json_encode($response);
        }
        else
        {
            $response["code"] = 12;
            $response["message"] = "Query empty, nothing to select";
            echo json_encode($response);
        }

それを修正する方法を知っている体はありますか?ありがとう。

4

1 に答える 1

1

初期化したときの応答の s を忘れました

于 2013-06-08T00:23:38.513 に答える