But how insert.php and another page which contain second code to retrieve image from database is connected
can u plz expalin me
That's because you executed print() before header().
The header() function should never be executed after any functions that's intrinsically sends a header like print() or echo().
Try reading this post of mine on previous pages for a user who had a similar problem as yours.
And on this thread page is the original breakdown of what I came up to store and display the image.
Sorry for the late reply, but HTH.
Last edited by k1net1cs; 05-07-2010 at 11:47 AM. Reason: forum's url parsing fail... -_-;
Jaan,
Can you please help me with a little query I have. I want to be only show thumbnails of the images and not a full image on the page. How can that be achieved with a little caption at the bottom of the picture to say the person's name??
I am a newbie to programming and any help you provide is much apprecaited.
my email is qakbar@hotmail.co.uk
Thank you
HI,
I need to display images in a table and resize the images ho do i do this?
Hi
I used same code... But did not get image. It is showing cross instead of image...
Code:
Code:<?
if(isset($_GET['id']))
{
header('Content-type: image/jpeg'); // act as a jpeg file
mysql_connect('localhost','root','')or die(mysql_error());
@mysql_select_db('test')or die(mysql_error()); // use the ‘test’ database
$query = 'select * from images where id = $id';
$result = mysql_db_query('test',$query)or die(mysql_error());
$row = mysql_fetch_array($result);
$img = $row['img'];
echo ($img);
}
else{echo 'id is not send';}
?>
Last edited by Jaan; 07-09-2010 at 04:25 PM. Reason: Please use code tags when you are posting your codes!
Hi guys
My problem is I have loaded image into data base, but when I was trying to get this, it was showing cross....
Code:
Code:<?php echo "<p>Recent uploads</p>"; // Connect to the database server $dbcnx = @mysql_connect('localhost', 'root', 'root'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } // Select the pictures database if (!@mysql_select_db('pictures')) { exit('<p>Unable to locate the Pictures ' . 'database at this time.</p>'); } // Request the id, title, img of files $result = @mysql_query('SELECT id, title, images FROM details'); if (!$result) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } // Display $result in a paragraph while ($row = mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; $img = $row['images']; header('Content-type : image/jpg'); echo '<blockquote>' . $id, $title, $img .'</blockquote>'; } ?>
lrearth, as answer to you, as to just about everyone here (if you have read the thread you'd know) you can't put any other code into the show.php file! it has to be exactly as it was written. it needs to be stand alone and to be called upon as it was a image file on disk, like <img src="show.php?id=12">
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
Hi,
I used this code -
I tried url this - http://localhost/kabaap/getImage.php?id=10Code:<?php if($_GET['id']) { $id = $_GET['id']; if (! @MYSQL_CONNECT("localhost","root","sslmtk13")) { print "Cannot connect to database"; } print "Id = $id"; @mysql_select_db("test"); $query = "select bin_data,filetype from binary_data where id='$id'"; $result = @MYSQL_QUERY($query) or die('Bad query at 12!'.mysql_error()); $data = @MYSQL_RESULT($result,0,"bin_data"); $type = @MYSQL_RESULT($result,0,"filetype"); Header( "Content-type: $type"); echo $data; } else { print "No Id"; } ?>
I got output -
Code:http://localhost/kabaap/getImage.php?id=10
Upload code:
Display code:Code:<?php $q=$_GET["q"]; $con = mysql_connect("****************************************"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("aarclients", $con); ?> <form method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> <?php if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$q')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; } ?>
All im getting is blank page..Code:<?php $con = mysql_connect("*******************************"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("aarclients", $con); $id = $_GET['id']; if(!isset($id) || empty($id)){ die("Please select your image!"); } else{ $query = mysql_query("SELECT * FROM upload WHERE debtor_id='".$id."'"); $row_image = mysql_fetch_array($query); $content = $row_image['content']; $filetype = $row_image['type']; header("Content-type: $filetype"); echo $content; } ?>
hello Jaan, I am trying similar things as you explained above, but the image is not getting display on the page, it shows the place holder on the page with a samll cross mark at the top. here is my code
I am a beginner in php, so if I am missing any reference, please let me know.
the page which is displaying the image -
and the page which is retrieving he image -HTML Code:<html> <head> <style type="text/css"> .background { background-image:url(back.png);background-repeat:repeat-x; } </style> <title>PHP Test</title> </head> <body> <div Class="background"> <table style="width:100%; height:100px;"> <tr> <td width="100%" align="center" height="100px"> <!-- Banner --> My Page </td> </tr> </table> <table style="width:100%; height:100px;"> <tr> <td> <!-- Image1 --> <img src="getImage.php" height="100px" width="70"/> </td > <td width="30%" style="height:100px;"> <!-- Image2 --> </td> <td width="30%" style="height:100px;"> <!-- Image3 --> image 3 </td> </tr> </table> </div> </body> </html>
your response is highly appriciated..Code:<?php
mysql_connect("localhost","root","mysql") or die("Unable to connect to SQL server");
@mysql_select_db("database") or die("Unable to select database");
$result=mysql_query("select * from table_name where rowid=1") or die("Can't perform Query");
$data=@MYSQL_RESULT($result,0,"content_image");
header('Content-Length: '.strlen($data));
header('Content-Disposition: inline; filename="add1.jpg"');
header('Content-type: image/jpg');
echo($data);
?>
Last edited by Jaan; 08-03-2010 at 03:31 AM. Reason: Please use code tags when you are posting your codes!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks