| | |
A confusing php problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 140
Reputation:
Solved Threads: 0
I need to delete a file using php function and then redirected the page to another one.
I tried with this code :
-----------------------------------------
Works fine in my local host but the following error coming when upload to server :
The permission of the directory is 777 and i tried my level best...
Please help me
Thanks in advance
I tried with this code :
-----------------------------------------
delete("$file");
function delete($file){
unlink ($file);
header("Location: npp.php");
}Works fine in my local host but the following error coming when upload to server :
Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/test/np.php:6) in /home/mysite/public_html/test/np.php on line 7 The permission of the directory is 777 and i tried my level best...
Please help me
Thanks in advance
Last edited by rajeesh_rsn; Mar 30th, 2009 at 11:40 am. Reason: mistake
•
•
Join Date: Aug 2005
Posts: 150
Reputation:
Solved Threads: 13
It seems, as if you can't unlink the file. Try to write an @ before unlink (eg @unlink()). That makes the PHP engine not to print the error occured.
I can't tell you, why you don't have the permission to unlink the file but at least the execution of your script will be fine.
I can't tell you, why you don't have the permission to unlink the file but at least the execution of your script will be fine.
•
•
Join Date: Mar 2009
Posts: 3
Reputation:
Solved Threads: 0
hi,
the unlinking is happening fine. the problem is headers are already sent so u cannot use header(Location:xxx.php). my shortcut to the problem is this. use javascript to redirect to the new page. do something like this echo "<script>window.location.href='abc.php'</script>";
now put this line where u have the header(Location: ) line and it will work hopefully.
hope this helps
the unlinking is happening fine. the problem is headers are already sent so u cannot use header(Location:xxx.php). my shortcut to the problem is this. use javascript to redirect to the new page. do something like this echo "<script>window.location.href='abc.php'</script>";
now put this line where u have the header(Location: ) line and it will work hopefully.
hope this helps
Last edited by hooka85; Mar 30th, 2009 at 4:16 pm.
![]() |
Similar Threads
- Apache (Linux Servers and Apache)
- PHP Variables through Checkboxes (PHP)
- Multiple items with the same id problem (edit-in-place) (JavaScript / DHTML / AJAX)
- inserting checkbox values in mysql +PHP (PHP)
- PHP downloading? (PHP)
- problem logging on to yahoo mail (Web Browsers)
- Programming Question Using PHP Language (PHP)
- Floating Menus: I have a problem, can you help me figure it out? (HTML and CSS)
- php mysql help (PHP)
- JoeOneEye- prosearching.com problem (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Help! Notice: Undefined index
- Next Thread: PHP Drop Down Box - Help
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code cron curl data database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link links login loop mail md5 menu mlm mod_rewrite multiple mysql mysql_real_escape_string oop parse paypal pdf php problem query radio random recursion regex remote replace script search searchbox server session sessions sms soap source space sql structure syntax system table tutorial update upload url validation validator variable video votedown web website xml youtube





