Hi this is my first post on DaniWeb.... the information has helped me in the past but im seriously stuck.... Help would be very much appreciated..

Im trying to create a form where the user can upload 5 pictures to a mysql database (members) field names are img1, img2, img3, img4, img5.. i have read to design the img fields as varchar100 ??? and for my form to insert the location of the files?? into the database.
********upload form

<html>

<form action='upload.php' method='post' enctype='multipart/form-data'>
	<input type='file' name='myfile'>
    <input type='file' name='myfile1'><br>
    <input type='file' name='myfile2'>
    <input type='file' name='myfile2'><p>
    <input type='file' name='myfile4'>
    <input type='submit' value='upload'>

</form>
</html>

*******

I'v got one file uploading to a "uploaded" folder
***see below

<?php
// properties of uploaded file
$name = ($_FILES["myfile"]["name"]);
//$name = $_FILES["myfile"]["name"];
//$name = $_FILES["myfile2"]["name"];
//$name = $_FILES["myfile3"]["name"];
//$name = $_FILES["myfile4"]["name"];
$type = $_FILES["myfile"] ["type"];
$size = $_FILES["myfile"] ["size"];
$tempd = $_FILES["myfile"] ["tmp_name"];
$error = $_FILES["myfile"] ["error"];

if ($error > 0)
die ("Error uploading file code $error.");

else
{
	if ($type == "image/png" || $size > 500000) //file conditions
	{
		die ("File exceeds maximum file size limit of 0.5mb, saving the file as a JPG or GIF will reduce the overall size of the file");
	}
else
	move_uploaded_file($tempd,"uploaded/".$name);
		echo "Upload Completed";
	{	
		
} // end if, after else

} //end if b4 else

?>

but what i dont understand is how i tell the database where the file is ?? and how do i show the file in a mysql query... I have my search working fine as the results are what im expecting them to be...
but these F'n images just will not show >> please please help

***my search

echo "$foundnum results found<br><p>";
		
		while ($runrows = mysql_fetch_assoc($run))
		{
		//get data
		$category = $runrows['catname'];
		//$subcategory = $runrows['subcategory'];
		$subcats = $runrows['subcats'];
		$catdes = $runrows['catdes'];
		$keywords = $runrows['keywords'];
		$imagelocation = $runrows['imagelocation'];
		$img2 = $runrows['img2'];
		//$img2 src='image/".$row['imagelocation']."' width='50' height='50'>
		//show data as search results
		echo "
		$category<p><br>
		$subcats<br>
		$catdes<br><p>
		$keywords<p>
		$imagelocation //enctype='multipart/form-data'
		$img2 <img2 src='image/".$row['imagelocation']."' width='50' height='50'> 
		<img src='store/".$row['imagelocation']."' width='100' height='100' enctype='multipart/form-data'>
		$img2<p>
		
		";

many many thanks in advance if anyone can help me...

Mr. DaveyMoyes
you havent inserted the filename/path in to database while uploading. I this is why the file name is not showing.
Try inserting those img names to corresponding columns.

Mr. DaveyMoyes
you havent inserted the filename/path in to database while uploading. I this is why the file name is not showing.
Try inserting those img names to corresponding columns.

**** hi many thanks.... How can i do this.... im really new to php and this is causing me sooo many sleepless nights....

Can you help me on this please....

plz dont get me wrong, i think u already know this.
but what to do this is the answer.

mysql_query("INSERT INTO table_name (member, img1, img2,img3) VALUES ($var1, $var2, $var3, $var4)");

hi, it might be late, but i already manage to store 5 image at one time in blob. Can refer to below code..Can refer to attachment for full code.hopefully might help you.

if ($submit == "Simpan Aktiviti") 
{
	//insert into event table
	$sqlm = "INSERT INTO event (bilangan_e,tarikh,keterangan_e,turutan) VALUES ('$bilangan_e','$tarikh','$keterangan_e','$bilangan_e')";    
    $result = mysql_query($sqlm);
	
	
	//insert into event_details
	
	if(isset($Ya)== "checked")
	{
	  for($i = 1;$i<6 ;$i++)
	  {	
	  	
	  		$kom =  $_POST['komen_gambar'.$i];
			
			global $strDesc;
			$max_size = 1000000000;
			$fileUpload = $HTTP_POST_FILES['fileUpload'.$i]['tmp_name'] ;
			if($fileUpload != NULL)
			{
				  $fileUpload_name=$HTTP_POST_FILES['fileUpload'.$i]['name'];
				  $fileUpload_size=$HTTP_POST_FILES['fileUpload'.$i]['size'];
				  $fileUpload_type=$HTTP_POST_FILES['fileUpload'.$i]['type'];
				
				  $fileHandle=fopen($fileUpload, "rb");
				  $fileContent=fread($fileHandle,filesize($fileUpload));
				  $fileContent=addslashes($fileContent);
				  fclose($fileHandle);
				
				//checking pic - only can add 5 image
				$sqlcheck = "SELECT * from event_detail WHERE bilangan_e = '$bilangan_e'"  ;
				$result = mysql_query($sqlcheck);
   				$myrow1 = mysql_fetch_array($result);
				$kira = mysql_num_rows($result);
				if ($kira < 6)
				{
			      $kira = $kira + 1;
				  $sqls = "INSERT INTO event_detail (bilangan_e,tarikh,bilangan_ed,gambar,keterangan,jenis_gambar,tarikh_kemaskini) VALUES 
                  ('$bilangan_e','$tarikh',$kira,'$fileContent','$kom','$fileUpload_type',NOW())";    
      				$result = mysql_query($sqls);
					
					$message= '<span style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000; ">Maklumat event baru dan upload gambar telah berjaya dimasukkan.</span><br>';
				}
				else
				{
					$message= '<span  style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000;">Maaf.Anda telah melebihi had upload gambar sebanyak lima (5).</span><br>';
					
					
				}
				
				  
			}//if fileupload null
	  }//for
	}
	else
	{
		$message= '<span style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000; ">Maklumat event baru dan upload gambar telah berjaya dimasukkan.</span><br>';
	}
	
	
	$flag = true;
}
else
{
	$message ="";
	$flag = false;
}
Attachments
<html>
<head>
<? session_start();?>
<!--<link rel="SHORTCUT ICON" href="http://www.jpph.gov.my/V1/images/jpph.ico"/>-->
<link rel="stylesheet" type="text/css" media="all" href="Kalendar/calendar-win2k-cold-1.css" title="win2k-cold-1" />
<!-- main calendar program -->
		  <script type="text/javascript" src="Kalendar/calendar.js"></script>
		
		  <!-- language for the calendar -->
		  <script type="text/javascript" src="Kalendar/lang/calendar-en.js"></script>
		
		  <!-- the following script defines the Calendar.setup helper function, which makes
			   adding a calendar a matter of 1 or 2 lines of code. -->
		  <script type="text/javascript" src="Kalendar/calendar-setup.js"></script>
<title>SISTEM PENGURUSAN LAMAN WEB JPPH Versi 1.0</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">


  <script language="javascript">
function showMe (it, box) {
var vis = (box.checked) ? "block" : "none";
document.getElementById(it).style.display = vis;
}
//validate form
function validate_requiredlength(field,alerttxt)
{
	with (field)
	{
	
		if (value.length < 0 )
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return true;
		}
	}
}
 
function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value==""||value=="<center> - </center>")
		{
			alert(alerttxt);
			return false;
		}
		else 
		{
			return true;
		}
	}
}
function validate_required_pic(Ya,fileUpload1,alerttxt)
{
	with (Ya,fileUpload1)
	{
		if (Ya.checked ==true)
		{
			if (fileUpload1.value==null||fileUpload1.value==""||fileUpload1.value=="<center> - </center>")
			{
				alert(alerttxt);
				return false;
			}
		}
		else 
		{
			return true;
		}
	}
}


function validate_formBM(mainForm)
{
	with (mainForm)
	{
	 if (validate_required(mainForm.keterangan_e,"Sila isi keterangan aktiviti")==false)
	  {mainForm.keterangan_e.focus();return false;}
	 if (validate_required(mainForm.tarikh,"Sila pilih tarikh.")==false)
	  {mainForm.tarikh.focus();return false;}
	 if (validate_required_pic(mainForm.Ya,mainForm.fileUpload1,"Sila isi minimum satu(1) gambar.")==false)
	  {
	  	mainForm.fileUpload1.focus();return false;
	  }
	}
}

</script>
<head>
  <link href="forAll.css" rel="stylesheet" type="text/css">
  </head>

 <? include ("header.php"); ?>

    
  
  <tr> 
    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr> 
          <td width="23%" valign="top"> 

 <? include ("left.php"); ?>
 
  		  </td>
          <td valign="top" width="77%">


            <p>
  <style type="text/css" media="screen">
	body { background-color:#ffffff; }
		.content 
		    {
			background-color:#f5f5f5;
			padding-top:10px; padding-right:10px;
			padding-bottom:10px; padding-left:10px;
			margin-top:10px; margin-right:10px;
			margin-bottom:10px; margin-left:10px;
			}
		a.navlink:link 
		    {
			color:#0033CC;
			text-decoration:none;
			}
		a.navlink:visited
			{
			color:#0033CC;
			text-decoration:none
			}
		a.navlink:hover
			{
			color:#ffffff;
			text-decoration:none;
			}
			
		td 	{
			font-family:Verdana, Arial, Helvetica, sans-serif: 12px;
			vertical-align:top;
			}
			
		.title
			{
			font-size:20px; font-weight:normal;
			color:#ffffff;
			margin-top:5px; margin-bottom:5px; margin-left:20px;
			padding-top:5px; padding-bottom:5px; padding-left:20px;
			}
			
		.titlefooter
			{
			font-size:10px; font-weight:normal;
			color:#ffffff;
			margin-top:2px; margin-bottom:2px; margin-left:20px;
			padding-top:2px; padding-bottom:2px; padding-left:20px;
			}
		
		.smalltitle
			{
			font-size:12px; font-weight:normal;
			color:#0033CC;
			margin-top:2px; margin-bottom:2px; margin-left:20px;
			padding-top:2px; padding-bottom:2px; padding-left:20px;
			}
			
		.smalltitlebold
			{
			font-size:12px; font-weight:bold;
			color:#0033CC;
			margin-top:2px; margin-bottom:2px; margin-left:20px;
			padding-top:2px; padding-bottom:2px; padding-left:20px;
			}	
.style2 {
	font-size: 10px;
	font-family: Arial, Helvetica, sans-serif;
	color: #0033CC;
}
.style5 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 9px;
	color: #0033CC;
}
</style>
              
              
  </head>
  <body">
  <? 
include "dbmyJPPH.php";
$sql2 ="select max(turutan) as max1 from event order by turutan";
$result2= mysql_query($sql2);
$view = mysql_fetch_array($result2);
$tambah = $view['max1'];

$bilangan_e = $view['max1']+1;	 

$flag = false;
$message ="";	
if ($submit == "Simpan Aktiviti") 
{
	//insert into event table
	$sqlm = "INSERT INTO event (bilangan_e,tarikh,keterangan_e,turutan) VALUES ('$bilangan_e','$tarikh','$keterangan_e','$bilangan_e')";    
    $result = mysql_query($sqlm);
	
	
	//insert into event_details
	
	if(isset($Ya)== "checked")
	{
	  for($i = 1;$i<6 ;$i++)
	  {	
	  	
	  		$kom =  $_POST['komen_gambar'.$i];
			
			global $strDesc;
			$max_size = 1000000000;
			$fileUpload = $HTTP_POST_FILES['fileUpload'.$i]['tmp_name'] ;
			if($fileUpload != NULL)
			{
				  $fileUpload_name=$HTTP_POST_FILES['fileUpload'.$i]['name'];
				  $fileUpload_size=$HTTP_POST_FILES['fileUpload'.$i]['size'];
				  $fileUpload_type=$HTTP_POST_FILES['fileUpload'.$i]['type'];
				
				  $fileHandle=fopen($fileUpload, "rb");
				  $fileContent=fread($fileHandle,filesize($fileUpload));
				  $fileContent=addslashes($fileContent);
				  fclose($fileHandle);
				
				//checking pic - only can add 5 image
				$sqlcheck = "SELECT * from event_detail WHERE bilangan_e = '$bilangan_e'"  ;
				$result = mysql_query($sqlcheck);
   				$myrow1 = mysql_fetch_array($result);
				$kira = mysql_num_rows($result);
				if ($kira < 6)
				{
			      $kira = $kira + 1;
				  $sqls = "INSERT INTO event_detail (bilangan_e,tarikh,bilangan_ed,gambar,keterangan,jenis_gambar,tarikh_kemaskini) VALUES 
                  ('$bilangan_e','$tarikh',$kira,'$fileContent','$kom','$fileUpload_type',NOW())";    
      				$result = mysql_query($sqls);
					
					$message= '<span style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000; ">Maklumat event baru dan upload gambar telah berjaya dimasukkan.</span><br>';
				}
				else
				{
					$message= '<span  style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000;">Maaf.Anda telah melebihi had upload gambar sebanyak lima (5).</span><br>';
					
					
				}
				
				  
			}//if fileupload null
	  }//for
	}
	else
	{
		$message= '<span style="width: 600; height: 30; font-size: 20px; font-family: verdana; color: #FF0000; ">Maklumat event baru dan upload gambar telah berjaya dimasukkan.</span><br>';
	}
	
	
	$flag = true;
}
else
{
	$message ="";
	$flag = false;
}

?>
</p>
            <p><br>
              <br>
              </p>
            <div align="center"> <? 

?></div>
<form enctype="multipart/form-data" action="" method="post" name="mainForm" id="mainForm" >
  <table width="100%" border="1" align="center">
    <tr  bgcolor="#C0C0C0">
      <td colspan="2" class="forTitle"><strong> Aktiviti  Baru</strong></td>
    </tr>
    <tr>
      <td class="fornormalTexts">Tajuk Aktiviti </td>
      <td><label>
      <input type="Text" name="keterangan_e" size="60" value="<?php if(isset($_POST['keterangan_e'])) echo $_POST['keterangan_e']; ?>" maxlength="45" >
      <input name="hide_keterangan" type="hidden" id="hide_keterangan" value="<? echo $keterangan_e; ?>">
      <input name="hide_tarikh" type="hidden" id="hide_tarikh" value="<? echo $tarikh;?>">
      <input name="hide_bilangan" type="hidden" id="hide_bilangan" value="<? echo $bilangan_e;?>">
    </label></td>
    </tr>
    <tr>
      <td class="fornormalTexts">Tarikh Aktiviti </td>
      <td><label>
      <input name="tarikh" type="date" id="tarikh" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt" size="10" maxlength="10"  value="<?php if(isset($_POST['tarikh'])) echo $_POST['tarikh']; ?>">
      <img src="Kalendar/img.gif" width="18" height="18" align="absmiddle" id="f_trigger_a" style="cursor: pointer; border: 1px solid red;" title="Klik di sini untuk pengisian tarikh "
			  onmouseover="this.style.background='red';" onMouseOut="this.style.background=''" />
      <script type="text/javascript">
			          
			Calendar.setup({
				inputField     :    "tarikh",     // id of the input field
				ifFormat       :    "y-mm-dd",      // format of the input field
				button         :    "f_trigger_a",  // trigger for the calendar (button ID)
				align          :    "Bl",           // alignment (defaults to "Bl")
				singleClick    :    true
			});
		</script>
 </label></td>
    </tr>
    <tr>
      <td rowspan="2" class="fornormalTexts">Upload  sekarang ? </td>
      <td><label>
        <input name="Ya" type="checkbox" onClick="showMe('div1', this)" value="checked">
      </label>        <label><span class="fornormalTexts">Ya</span></label></td>
    </tr>
    <tr>
      <td><div id="div1" style="display:block; display:none;"><label>
	  
        <input name="fileUpload1"  type="file" id="fileUpload1"  size="50">
		
        <span class="name style2"><a  ></a></span></label>
          <label>
          <span class="fornormalTexts">Komen  </span>
          <input name="komen_gambar1" type="text" id="komen_gambar" value="<?php if(isset($_POST['komen_gambar1'])) echo $_POST['komen_gambar1']; ?>">
          </label>
          <br>
          <br>
          <label>
          <input name="fileUpload2"  type="file"  size="50">
          </label>
          <span class="fornormalTexts">Komen </span> 
          <input name="komen_gambar2" type="text" id="komen_gambar2" value="<?php if(isset($_POST['komen_gambar2'])) echo $_POST['komen_gambar2']; ?>">
          <br>
          <br>
          <input name="fileUpload3"  type="file" size="50">
          <span class="fornormalTexts">Komen </span>
          <input name="komen_gambar3" type="text" id="komen_gambar3" value="<?php if(isset($_POST['komen_gambar3'])) echo $_POST['
This article has been dead for over six months. Start a new discussion instead.