Hi everyone, I am new here and new to php. I am working on a form with a image upload. I have to upload the image to the image folder and then write the image name to a mysql database. I am able to upload the image but I am unable to write the image name to the database.
PHP:
<?php include(“db_connect.php”);?>
<?php // select the database in which to add a table
mysql_select_db(“final_exam_db”,$con);
$sql =”INSERT INTO drivers_0115061 (ln,fn,month,day,year,img,email)
VALUES (‘”.$_POST[“ln”].”‘,
‘”.$
‘”.$_POST[“month”].”‘,
‘”.$
‘”.$_POST[“year”].”‘,
‘”.$
‘”.$_POST[“email”].”‘
)”;
//$sql=”INSERT INTO people (fn,ln,dob,city,prov,pc,gender,hc,nod) VALUES (‘steve’,’douglas’,1234567,’winnipeg’,’manitoba’,’r3p 6g5′,’m’,’grey’,2)”;
//echo $sql;
mysql_query($sql, $con);
echo mysql_error();
?>
<?php
$target_folder=”images/”;
$target_file=$target_folder.basename($_FILES[“img”][“img”]);
// if(move_uploaded_file($
// {
// echo “It Worked!”;
// echo “<a href='”.$target_file.”‘target=’_blank’/>”.$target_file.”</a>”;
// }
// else
// {
// echo “Crap No Go!”;
// }
?>
<?php include(“db_close.php”);?>
html form (snippet):
<td>
Picture
</td>
<td>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”10000000″/>
<input type=”file” id=”img” name=”img”/>
</td>
If anyone can help me out I would be forever grateful.
Thanks in advance,
Vince