Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Problem with Josn Data

$
0
0

I have recived a set of dat from an android device using Json. I have decoded this data into a PHP array. I took each value of the array usinf foreach and placed in a MySQL statement. But its not working. Can any body help me. Given below is my code.

       	$array=$_POST['nuer']; //numbers fetched 

        $jstring = (array)json_decode($array);
 
        foreach($jstring  as $value ) //loop over values
         {

         
         $four = mb_substr($value, 0,-10); //to get the first chara's
         $ten = mb_substr($value, -10); // to get the last ten chara


               $con=mysqli_connect("localhost","app","test","appt"); //connection to the database

	       $result = mysqli_query($con, "SELECT * FROM profile WHERE (mobileno IN '$ten') AND (code IN '$four')");
               while($row = mysqli_fetch_array($result, MYSQL_ASSOC))
                {

                $friend[] = $row[id];

                }
               mysqli_close($con);

$result is returning a null value. When i used a user defined array with random value, this code worked perfectly. Thanks in Advance.


Viewing all articles
Browse latest Browse all 13200

Trending Articles