sandbudd Posted June 30, 2008 Share Posted June 30, 2008 I am having a problem when loaded all it does is show a blank page and does not show in the database? <?php $uploaddir = "upload/"; $MaxSize = "600000"; $db_host = ''; $db_user = ''; $db_pwd = ''; $database = ''; $table = ''; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); function execSQL($strSQL_filenames) { if (!$strSQL_filenames == 0) { $query = "INSERT INTO upload (id, filename,description) VALUES (NULL,'$strSQL_filenames',NULL)"; echo "$query"; $result = mysql_query($query) or die("ERROR: cannot INSERT data into database, check your permissions"); } else { echo "NOTE: Please select a file to upload"; } } $number_of_files = count($_FILES['userfile']); $filename_format = uniqid(img); if (!$_FILES['userfile']['size'][$i] == 0) if ($_FILES['userfile']['size'][$i] > $MaxSize) { echo "ERROR: File too Large"; echo "<br><a href='" . $_SERVER['SCRIPT_NAME'] ."'>Try again..</a>"; exit; } $tempfile = $_FILES['userfile']['tmp_name'][$i]; $uploadfile = $_FILES['userfile']['name'][$i]; $file_description = $_POST['description']; $extension = $_FILES['userfile']['type'][$i]; if (strstr($extension,"jpeg")) { $extension=".jpg"; } elseif (strstr($extension,"gif")) { $extension=".gif"; } else { echo "ERROR: That type of file is not allowed. only gif/jpeg allowed."; echo "<br><a href='" . $_SERVER['SCRIPT_NAME'] ."'>Try Again..</a>"; exit; } if(copy($tempfile, $uploaddir.$uploadfile)) { echo "Copy Successfull!<br>"; } else { echo "ERROR: the temp file to the specified folder"; } if(rename($uploaddir.$uploadfile,$uploaddir.$filename_format.$extension)) { echo "The File: " . $_FILES['userfile']['name'][$i] . " uploaded successfully"; echo " and renamed to $filename_format$extension"; } else { echo "ERROR: Problem renaming the file.. $uploadfile"; } echo "<p>"; if($i=="0") { $strSQL_filenames = "$filename_format$extension"; } elseif($i>0) $strSQL_filenames = $strSQL_filenames . " $filename_format$extension"; } } if($i==$number_of_files) { execSQL($strSQL_filenames); if($strSQL_filenames) { echo "The following data was entered into the database: \"" . $strSQL_filenames ."\""; } } } ?> <html> <head> </head> <body> <form name="form1" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data"> <input type="file" name="userfile[]" style="width:300;"><br> <input type="file" name="userfile[]" style="width:300;"><br> <input type="file" name="userfile[]" style="width:300;"><br> <input type="file" name="userfile[]" style="width:300;"><br> <input type="submit" value="Upload/Submit"> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/112520-solved-script-problem/ Share on other sites More sharing options...
darkfreaks Posted June 30, 2008 Share Posted June 30, 2008 error reporting ini_set('error_reporting',E_ALL); Link to comment https://forums.phpfreaks.com/topic/112520-solved-script-problem/#findComment-577739 Share on other sites More sharing options...
sandbudd Posted June 30, 2008 Author Share Posted June 30, 2008 Do I just insert that anywhere in the code because I did and still nothing? Link to comment https://forums.phpfreaks.com/topic/112520-solved-script-problem/#findComment-577746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.