Filename to MySql database
Posted: Wed Nov 18, 2009 4:08 am
Hello guys.
I am upload 2 files to my server, and I want to save the 2 filenames to my MySQL Database.
I have called them "picname1" and "picname".
How do I do this??? I have tried, with this code - but it will not work.
I dont know if its possible to give the database name a variable like I try???
Please help.
$noFiles = count($_FILES["minfil"]["name"]);
for($i = 0; $i < $noFiles; $i++) {
move_uploaded_file($_FILES["minfil"]["tmp_name"][$i],"upload/" . $_FILES["minfil"]["name"][$i]);
$picName = $_FILES['minfil']['name'][$i];
$sql = "INSERT INTO show_nyheder ('picname[$i]') VALUES('picName[$i]');";
mysql_query($sql);
}
I am upload 2 files to my server, and I want to save the 2 filenames to my MySQL Database.
I have called them "picname1" and "picname".
How do I do this??? I have tried, with this code - but it will not work.
I dont know if its possible to give the database name a variable like I try???
Please help.
$noFiles = count($_FILES["minfil"]["name"]);
for($i = 0; $i < $noFiles; $i++) {
move_uploaded_file($_FILES["minfil"]["tmp_name"][$i],"upload/" . $_FILES["minfil"]["name"][$i]);
$picName = $_FILES['minfil']['name'][$i];
$sql = "INSERT INTO show_nyheder ('picname[$i]') VALUES('picName[$i]');";
mysql_query($sql);
}