Jump to content

Code won't print


johnseito

Recommended Posts

If i input this code

Code:

 

header("Location: " . $_SERVER['PHP_SELF']);

 

after this code

Code:

 

mysql_query("insert into upload3(photo, caption) values('$fileName','$caption')");

 

this code won't print

Code:

 

echo "<font color =red> The file </font><b>". basename( $_FILES['uploaded']['name']). "</b> <font color=red>has been uploaded to the</font>". "<b> $dir </b></font>"."<font color=red> directory.</font><br><br>";

 

Code:

mysql_query("insert into upload3(photo, caption) values('$fileName','$caption')");
header("Location: " . $_SERVER['PHP_SELF']);
echo "<font color =red> The file </font><b>". basename( $_FILES['uploaded']['name']). "</b> <font color=red>has been uploaded to the</font>". "<b> $dir </b></font>"."<font color=red> directory.</font><br><br>";

 

Do you know why or how I can fix it?

 

thanks

 

Link to comment
Share on other sites

header("Location: " . $_SERVER['PHP_SELF']);

The header("Location:.... function instantly redirects the script to the target location - anything after this point is ignored by the script and so will not be printed.  If you want to show the text for a little while and then redirect, you should use the html <meta> tag.

<?php
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5; URL=".$_SERVER['PHP_SELF']."\">";
?>

You need to put this into the <head> tag of your page though, so it might not be appropriate.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.