Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2.  header("Content-type: image/jpeg");
  3.  $host="localhost"; // Host name
  4. $username="root"; // Mysql username
  5. $password=""; // Mysql password
  6. $db_name="fb"; // Database name
  7. $tbl_name="users"; // Table name
  8.  
  9. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  10. mysql_select_db("$db_name")or die("cannot select DB");
  11.  
  12.  error_reporting(E_ALL);
  13.  
  14.         $regemail = $_SESSION['email'];
  15.         $sql = "SELECT image
  16.            FROM pictures JOIN users ON pictures.image_name = users.id AND
  17.            users.id = (SELECT id FROM users WHERE email = '$regemail') LIMIT 1; ";//$regemail
  18.  
  19.         // the result of the query
  20.         $result = mysql_query("$sql");//die("Invalid query: " . mysql_error());
  21.         if(!$result){
  22.             echo '<a href="#">Upload Image</a>';echo $result;
  23.             }else{
  24. //               echo mysql_result($result, 0);
  25.                $row = mysql_fetch_assoc($result);
  26.                 $imagebytes = $row['imgdata'];
  27.                  
  28.                 print $imagebytes;
  29. //                echo mysql_result($result, 0);
  30.             }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement