PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi. I'm having trouble with this script. It doesn't throw an error of any kind. But it 'echoes' nothing back either. Nothing is uploaded and nothing is created in the database. Help!
<?php
//Connect to the database here
require_once ('connect.php');
$file_upload="true";
$file_up_size=$_FILES[Picture][size];
if (!($_FILES[Picture][type] =="image/jpeg" OR $_FILES[Picture][type] =="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";}
$file_name=$_FILES[Picture][name];
$add="../personnel/$file_name"; // the path with the file name where the file will be stored, upload is the directory name.
if($file_upload=="true"){
if(move_uploaded_file ($_FILES['Picture'][tmp_name], $add)){
mysql_query("INSERT INTO personnel (memberName, memberPicture, memberDescription) VALUES('$_POST[memberName]', '$_FILES[Pictures][name]', '$_POST[memberDescription]')")
or die(mysql_error());
echo '<p> The new team member has been successfully added to the database! <a href="cms_personnel.php">Click here</a> if you are not automaticly redirected to the Personnel Database page in 5 seconds. </p>';
} else { echo '<p>Failed to upload file. Contact Site admin to fix the problem</p>'; }}
?>
My enctype is already setup to "multipart/form-data", all the tables exist with the fields (and names all match). Same for the name of the fields in the forms.
Last edited by ReX357 on Wed Apr 29, 2009 10:22 pm, edited 2 times in total.