0

This is my problem, how could i pass the variables from the android to the PHP? Please help me.. This my problem.

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/a3701630/public_html/getDesc.php on line 9

This is my PHP code.

<?php
    include 'config.php';
    connect();

    $userid= str_replace('_', ' ', mysql_escape_string($_POST['userid']));
    $sql = "SELECT description FROM tbl_userdescription WHERE userid = ". $userid;
    $result = mysql_query($sql); 

    while($row=mysql_fetch_assoc($result))
        $output[]=$row;

    print(json_encode($output));
?>
  • Can explain further? Are you trying to have an Android app call a web page? – ssaltman Jan 19 '14 at 22:28
  • what is the output of json_encode? do you get something? – hakkikonu Jan 19 '14 at 22:28
  • mysql_query (which is deprecated by the way) returns false if something went wrong during the query. So it's very likely that `$result` is false and not a result object. – tiguchi Jan 19 '14 at 22:28
  • possible duplicate of [mysql\_fetch\_assoc(): supplied argument is not a valid MySQL result resource](http://stackoverflow.com/questions/5646427/mysql-fetch-assoc-supplied-argument-is-not-a-valid-mysql-result-resource) –  Jan 19 '14 at 22:30
  • no, my web page is only for storing some data, my interface is in the android, how can i pass the data that i Inputted in my android to my webpage. please help – user3212302 Jan 19 '14 at 22:30
  • plese show us print(json_encode($output));'s result. – hakkikonu Jan 19 '14 at 22:35
  • The answer is null. :( but my table has a data. – user3212302 Jan 19 '14 at 22:38
  • You are replacing underscore with spaces in the userid? I would think you would need to put quotes around the result, if spaces in a userid are valid to begin with. – Andrea Jan 19 '14 at 23:43
  • Please post your android codes where you pass values to getDesc.php – Munir Basheer Jan 20 '14 at 03:08

0 Answers0