PHP showing null output
<p>I'm writing an android application that retrieves data belonging to a particular user. I'm using SharedPreference of Activity1 in Activity2.</p>

<p>here's the SharedPreference that I'm storing in Activity1</p>

<pre><code>SharedPreferences sp = getSharedPreferences("login details", 0);
SharedPreferences.Editor spedit = sp.edit();
spedit.putString("sPhone",sPhone);              
spedit.putString("sPassword", sPassword);
spedit.commit();
</code></pre>

<p>I'm using the above SharedPreference in Activity2 and sending it as a String to a PHP file:
The Activity2 code:</p>

<pre><code>SharedPreferences prefs = getSharedPreferences("login details", 0);
String str = prefs.getString("sPhone", "");

nameValuePairs.add(new BasicNameValuePair("userid", str));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httppost.setHeader("Content-type", "application/json");
response = httpclient.execute(httppost);
entity = response.getEntity();
is = entity.getContent();
</code></pre>

<p>Here's the PHP code:</p>

<pre><code>&lt;?php
mysql_connect("localhost","root","");
mysql_select_db("assigndroid");
header('content-type=application/json; charset=utf-8');

//$userID = isset($_POST['userid']) ? $_POST['userid'] : '';
$userID = mysql_real_escape_string($_POST['userid']);   

$sql=mysql_query("select * from newassignment where issuedBy='$userID';");
while($row=mysql_fetch_assoc($sql))
    $output[]=$row;
print(json_encode($output));
mysql_close();
?&gt;
</code></pre>

<p>But the SQL query is returning 'null'. I get an error saying "Undefined variable output". And due to this null value, the application is crashing on the emulator by saying a "FATAL EXCEPTION AsyncTask #1"</p>

<p>Can anyone help me out here? I urgently need this code for my project work which should be submitted on Friday. Please, can anyone help me out here? Thank you in advance! :)</p>
