Hi ..
thanks for your reply.. but now i face a new issue it when i go show.php
it opens as attachment no picture is viewed
please resolve this issue
thanks
please check
st-michaelsacademy.com/show.php
@helena :
The page shows the image just fine.
Try accessing the page with the id numbers, like this :
st-michaelsacademy.com/show.php?id=3
http://st-michaelsacademy.com/show.php?id=1
works fine for me..
i used:
Code:[IMG ]http://st-michaelsacademy.com/show.php?id=1[/IMG]
jaan, thanx for this tutorial, however, i have a DB with a table like this, employee_id,employee_name,employee_picture. I want to display the pictures with the corresponding name in a table. ow do i do that?
thank you for your time.
Hmm..
you can do it like this
or something like that..Code:$name = $_GET['name'];
$sql = "SELECT employee_picture FROM table_name WHERE employee_name='".mysql_real_escape_string($name)."'";
$query = mysql_query($query);
$row = mysql_fetch_array($query);
$image = $row['employee_image'];
try this
thanx jaan. But it didnt work. It brought out unreadable characters in the picture column of the table. Please assist.
Did you store the image as a BLOB type?
If you did, did you 'send' the image from your database with a correct header?
Or, did you use a separate PHP for fetching the images?
Kinetics is right, your image have to be "BLOB" in database and also when you are displaying your image you must define correct header
thanx everyone. YES, the image column is blob type. This is the complete script. Please check it out.
I checked the table and the blob column has values. I tried to display and to no avail.I need to display it in a table pix|staffid|name. The name and other information are kept in another table.Code:<?php
if(isset($_POST['submit1']) || !empty($_POST['submit1']) && !empty($_POST['txtID']) && $_FILES['userfile']['size'] > 0)
{
$msg=array();
$ref_db="";
$green_flag=0;
$the_staffid=$_POST['txtID'];
$ref_db="mydbsr";
$dbcon=funcReadWriteConn();
if(!$dbcon){
echo"<br />Could Not connect to the database, please try again later";
die();
}
$row_no=0;
$dbid=mysql_select_db($ref_db,$dbcon);
$query="";
$query="SELECT rtype FROM pixtable WHERE ucase(trim(rstaffid))='".strtoupper(trim($the_staffid))."'";
$rst=mysql_query($query,$dbcon);
if($rst) $row_no=mysql_num_rows($rst);
if($row_no>0){
$msg[]="<font color=red><br />Sory, this Picture has been previous uploaded, Pictures cannot be changed by you.";
mysql_free_result($rst);
mysql_close($dbcon);
$green_flag=0;
}
if($row_no<=0)//i.e pix has NOT been previous uploaded
{
$green_flag=1;
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$msg[]="File Sie:".$fileSize." File Type:".$fileType;
if($fileSize==0) {
$msg[]="<font color=red><br />No fle selected expecting maximum of 20KB.";
$green_flag=0;
}
if($fileSize>20000) {
$msg[]="<font color=red><br />Sorry, your file is too big (".$fileSize."Bytes) expecting maximum of 20KB";
$green_flag=0;
}
if($fileType==''){
$msg[]="<font color=red><br />Your file type is NOT known, configure your browser properly or use Firefox/IE 6 and above.";
$green_flag=0;
}
if($fileType!='image/jpeg'){
$msg[]="<font color=red><br />Sorry, your file type is (".$fileType.") expecting jpeg type.";
$green_flag=0;
}
if($green_flag==1)
{
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(get_magic_quotes_gpc()) $fileName = stripslashes($fileName);
$fileName=mysql_real_escape_string($fileName,$dbcon);
$query = "INSERT INTO pixtable (rstaffid, rsize, rtype, rpix ) VALUES ('$the_staffid', '$fileSize', '$fileType', '$content')";
$ret=mysql_query($query,$dbcon);
if(!$ret) die("Sorry, Could NOT upload");
if($ret) {$msg[]="<font color=red><br />Your Picture has been uploaded";$saved_flag=1;}
}//green_flag=1
mysql_close($dbcon);
}//row<0
}
?>
Thanx.
Last edited by Jaan; 01-19-2010 at 03:46 PM. Reason: Please use code tags when you are posting your codes!
I mean that i need to display in an HTML table with the following column pix|staffid|name|other_info. The name and other info are saved in another mysql table separate from the mysql pixtable.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks