/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] php empty

Hi

Heres my code:

[code=php]
<?

$files = $_POST[‘movie’];
$id = $_POST[‘id’];
$title = $_POST[‘title’];
$date = $_POST[‘date’];
$filepath = $_POST[‘filepath’];

if (empty($files)) {
$query = mysql_query(“UPDATE movie_manage
SET name=’$title’, date=’$date’ WHERE id=’$id'”);
echo ‘<BR>&nbsp&nbsp <font face=arial size=2><b>Thank you!<BR>&nbsp&nbsp Your Movie Remains at: ‘.$filepath.'<BR>&nbsp&nbsp With The Title Changed to ‘.$title.’ and to be displayed on ‘.$date.'<BR></b></font>’;

} else {

$uploaddir = ‘/hsphere/local/home/tanner/tannercreative.com/quest/files/’;
$uploadfile = $uploaddir . $id . basename($_FILES[‘movie’][‘name’]);
$file = basename($_FILES[‘movie’][‘name’]);
move_uploaded_file($_FILES[‘movie’][‘tmp_name’], $uploadfile);

$filepath = ‘/files/’.$file.”;
$query = mysql_query(“UPDATE movie_manage
SET name=’$title’, date=’$date’, file=’$filepath’ WHERE id=’$id'”);
echo ‘<BR>&nbsp&nbsp <font face=arial size=2><b>Thank you!<BR>&nbsp&nbsp Your Edit Movie: ‘.$file.’ is uploaded to ‘.$filepath.'<BR>&nbsp&nbsp With The Title Changed to ‘.$title.’ and to be displayed on ‘.$date.'<BR></b></font>’;
}

?>
[/code]

Basically what i want it too do is… if the $files is empty has no content… then it should display the information below it… that works fine… but if there is content in $files it just does the first one again… for some reason its not going to the else.

Thanks for any help
Aaron

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 31.2006 — Try a [b]print_r($_POST)[/b] and make sure the post array has the values you are expecting [i]and[/i] that the array keys are what you're expecting (including upper/lower case).
Copy linkTweet thisAlerts:
@LiL_aaronauthorAug 31.2006 — Hi

Thanks for the response... its not displaying the textfield in the array...

this is the text field:

[code=php]

<input type="file" name="movie" size="29">

[/code]


Do you think it may have anything to do with that the type is file?

Thanks

Aaron
Copy linkTweet thisAlerts:
@LiL_aaronauthorAug 31.2006 — I fixed it!

[code=php]
<?

$files = $_FILES['movie']['name'];
$id = $_POST['id'];
$title = $_POST['title'];
$date = $_POST['date'];
$filepath = $_POST['filepath'];

if (empty($files)) {
$query = mysql_query("UPDATE movie_manage
SET name='$title', date='$date' WHERE id='$id'");
echo '<BR>&nbsp&nbsp <font face=arial size=2><b>Thank you!<BR>&nbsp&nbsp Your Movie Remains at: '.$filepath.'<BR>&nbsp&nbsp With The Title Changed to '.$title.' and to be displayed on '.$date.'<BR></b></font>';

} else {

$uploaddir = '/hsphere/local/home/tanner/tannercreative.com/quest/files/';
$uploadfile = $uploaddir . $id . basename($_FILES['movie']['name']);
$file = basename($_FILES['movie']['name']);
move_uploaded_file($_FILES['movie']['tmp_name'], $uploadfile);

$filepath = '/files/'.$file.'';
$query = mysql_query("UPDATE movie_manage
SET name='$title', date='$date', file='$filepath' WHERE id='$id'");
echo '<BR>&nbsp&nbsp <font face=arial size=2><b>Thank you!<BR>&nbsp&nbsp Your Edit Movie: '.$file.' is uploaded to '.$filepath.'<BR>&nbsp&nbsp With The Title Changed to '.$title.' and to be displayed on '.$date.'<BR></b></font>';
}
?>
[/code]


Thanks for the help noggy doggy!!

Aaron
×

Success!

Help @LiL_aaron spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...