Log in

View Full Version : Whats rong with this



chrisgocrazyH
22-06-2007, 04:23 AM
Okay look at title

<?php
########## If add download was hit ##########
else if ($_GET['act'] == 'downloads') {

// If form sent
if ($_POST['add']) {
$title = mysql_real_escape_string($_POST['title']);
$description = mysql_real_escape_string($_POST['description']);
$date = date('n/j/y');
$imgUploadPath = $path.basename(''.$title.'_'.$_FILES['img']['name'].'');
$fileUploadPath = $filePath.basename("".$_FILES['files']['name']."");

// Check fields
if (!$title || !$date) { echo '<meta http-equiv="refresh" content="2;URL='.$_SERVER['PHP_SELF'].'?act=downloads" /> <span style="color: #FF0000">Please fill in all fields.</span>'; }

// Move file
else if (!move_uploaded_file($_FILES['img']['tmp_name'], $imgUploadPath)) { echo '<meta http-equiv="refresh" content="2;URL='.$_SERVER['PHP_SELF'].'?act=downloads" /> <span style="color: #FF0000">Error uploading the preview image</span>'; echo $path.basename(''.$title.'_'.$_FILES['img']['name'].'');}

else if (!move_uploaded_file($_FILES['files']['tmp_name'], fileUploadPath)) { echo '<meta http-equiv="refresh" content="2;URL='.$_SERVER['PHP_SELF'].'?act=downloads" /> <span style="color: #FF0000">Error uploading the file</span>'; }

else {
$insert = mysql_query("INSERT INTO `downloads` (id, title, description, url, img, date) VALUES ('', '$title', '$description', '$filePath".$_FILES['name']['files']."', '$path".$title."_".$_FILES['name']['img']."', '$date')") or die ("Error Inserting Download! \n<br />\n" .mysql_error());

echo '<meta http-equiv="refresh" content="2;URL=index.php" /> The download, <b>'.$title.'</b> has been added.';
}
}


// If form not sent
if (!$_POST['add']) { ?>

<!-- Add Download Form -->
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?act=downloads" title="add_news">
<table width="400" align="center">
<tr>
<td width="72">Title:</td>
<td width="316"><input type="text" name="title" /></td>
</tr>
<tr>
<td>Description:</td>
<td><input name="description" type="text" maxlength="200" /></td>
</tr>
<tr>
<td>Image:</td>
<td><input type="file" name="img" /></td>
</tr>
<tr>
<td>File:</td>
<td><input type="file" name="files" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="add" value="Add" /></td>
</tr>
</table>
</form>
<!-- /Add Download Form -->

<? }
}
?>

Eric30
22-06-2007, 10:23 AM
second line,
else if ($_GET['act'] == 'downloads') {

why have u got an else there :P

if ($_GET['act'] == 'downloads') {


Also post any error messages u get to help,

Ini
22-06-2007, 02:24 PM
3rd line actually ;]

chrisgocrazyH
24-06-2007, 09:06 AM
it wont show up now & Evan with the else in front it goes Fatal Error...


http://www.hmit.com.au/u.php

Want to hide these adverts? Register an account for free!