Instead of putting it on C, you'll need to put it in the context of a web
server that can handle PHP.  IIS, or Apache, for example.
--
Chris Stewart
http://chriswstewart.com

Fantasy 
Football<http://chriswstewart.com/android-applications/fantasy-football/>-
Android app for fantasy football fanatics and MFL owners
Social Updater<http://chriswstewart.com/android-applications/social-updater/>-
An easy way to send your status blast to multiple social networks



On Wed, Aug 18, 2010 at 7:51 AM, khalfaoui ameni
<[email protected]>wrote:

> thanks Sarwar Erfan for your answer,but can you tell me how i write
> the script and where i put it ??
> i tried to write a php script
>
> <?php
> $myServer = "98.130.0.21";
> $myUser = "********";
> $myPass = "******";
> $myDB = "######";
>
> //connection to the database
> $dbhandle = mssql_connect($myServer, $myUser, $myPass)
>  or die("Couldn't connect to SQL Server on $myServer");
>
> //select a database to work with
> $selected = mssql_select_db($myDB, $dbhandle)
>  or die("Couldn't open database $myDB");
>
> //declare the SQL statement that will query the database
> $query = "SELECT Id_Famille, Id_filiale, Designation ";
> $query .= "FROM T_Article ";
>
> while($e=mssql_fetch_assoc($query))
>        $output[]=$e;
>
> print(json_encode($output));
>
> //close the connection
> mssql_close($dbhandle);
> ?>
> and i put my scipt in my pc c:/
> in my application i write this :
>  String result = "";
>
>      ArrayList<NameValuePair> nameValuePairs = new
> ArrayList<NameValuePair>();
>
>      InputStream is = null;
>      //http post
>      try{
>              HttpClient httpclient = new DefaultHttpClient();
>              HttpPost httppost = new HttpPost("http://10.0.2.2/
> getAllArticle.php");
>
>              HttpResponse response = httpclient.execute(httppost);
>              HttpEntity entity = response.getEntity();
>              is = entity.getContent();
>      }catch(Exception e){
>              Log.e("log_tag", "Error in http connection
> "+e.toString());
>      }
>      //convert response to string
>      try{
>              BufferedReader reader = new BufferedReader(new
> InputStreamReader(is,"iso-8859-1"),8);
>              StringBuilder sb = new StringBuilder();
>              String line = null;
>              while ((line = reader.readLine()) != null) {
>                      sb.append(line + "\n");
>              }
>              is.close();
>
>              result=sb.toString();
>      }catch(Exception e){
>              Log.e("log_tag", "Error converting result
> "+e.toString());
>      }
>
>      //parse json data
>      try{
>              JSONArray jArray = new JSONArray(result);
>              for(int i=0;i<jArray.length();i++){
>                      JSONObject json_data = jArray.getJSONObject(i);
>                      Log.i("log_tag","id_famille:
> "+json_data.getString("Id_Famille")+
>                              ", id_filiale:
> "+json_data.getString("Id_filiale")+
>                              ", designation:
> "+json_data.getString("Designation ")
>
>                      );
>              }
>      }
>      catch(JSONException e){
>              Log.e("log_tag", "Error parsing data "+e.toString());
>      }
>    }
> but this code don't work
> 08-18 11:09:51.281: ERROR/log_tag(299): Error in http connection
> org.apache.http.NoHttpResponseException: The target server failed to
> respond
> 08-18 11:09:51.281: ERROR/log_tag(299): Error converting result
> java.lang.NullPointerException
> 08-18 11:09:51.311: ERROR/log_tag(299): Error parsing data
> org.json.JSONException: End of input at character 0 of
>
> could you please help me to fix it or did you have another way to do
> this?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to