0

I am trying to fetch image in php using Json.

The code I tried to use:

<?php 
    session_start(); 
    include("connect.php");
    echo "<br/>"; 
    echo $_SESSION['Reg_Id'];
    $result=mysql_query("SELECT * FROM registration where Email='".
        $_SESSION['Reg_Id']."'"); 

    while($row=mysql_fetch_array($result)) 
    { 
        $record[] = $row; 
    } 

    $data = json_encode($record); echo $data;
    echo '<img src="'.
        $data['http://localhost/NewFolder/UploadImage/IMG-20120823-WA0000.jpg'].
        '"; alt="sorry"/>'; 
?>
PleaseStand
  • 30,777
  • 6
  • 65
  • 95
  • Post some kind of code,also you can take a look to this: [http://stackoverflow.com/questions/5141986/sending-an-image-and-return-it-using-json](http://stackoverflow.com/questions/5141986/sending-an-image-and-return-it-using-json) – Sal00m Aug 30 '13 at 10:06
  • I was getting error on the URL .The error was Undefined index media – user2732468 Aug 30 '13 at 10:09
  • "; echo $_SESSION['Reg_Id']; $result=mysql_query("SELECT * FROM registration where Email='".$_SESSION['Reg_Id']."'"); while($row=mysql_fetch_array($result)) { $record[] = $row; } $data = json_encode($record); echo $data; echo 'sorry'; ?> – user2732468 Aug 30 '13 at 10:13
  • the code which i am using is post above – user2732468 Aug 30 '13 at 10:16
  • You can edit your question to put additional info. Just saying. – Andrius Naruševičius Aug 30 '13 at 10:22
  • What are you trying to do? Pull an image URL out of the DB? The last few lines of your code don't make much sense. Why would you use a hardcoded URL as an index into a *string* (which would have to be a non-negative integer)? – PleaseStand Aug 30 '13 at 10:36
  • I am trying to fetch image stored in my database through json in localhost – user2732468 Aug 30 '13 at 11:20

0 Answers0