sniperscope Posted September 2, 2009 Share Posted September 2, 2009 Hi gurus. I would like to ask that why this code takes a lot time to redirect to the index.php i want to go to index.php right away i click the Submit button but test.php runs at background. I am totally and :'( Great appreciate for any help Regards $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.example.com/admin/test.php"); curl_setopt($ch, CURLOPT_USERPWD, "user:pass"); $data = curl_exec($ch); header("location: index.php?r=1"); Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/ Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 Your script needs to wait for curl_exec() to finish before moving on to header(). Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910790 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 How can i redirect it without waiting? I changed header location and put on top of script but still o chance... So far i am digging exec command but my host safe_mode=on and still i have to wait. Shortly i am desperate Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910798 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 here is my exec command. But this command doesnt trigger test.php i put a small sql code which insert 1 line record and when i check db see nothing inserted. exec ("/home/project/public_html/example/admin/_cron/test.php >/dev/null &"); Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910800 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 Does test.php have a shebang line in it? Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910813 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 she bang you mean start with #/bin/usr ? No. There is no shebang. Should i add ? Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910816 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 You'll either need to add one or tell your shell which application you want to execute the script. eg; exec ("/usr/bin/php /home/project/public_html/example/admin/_cron/test.php >/dev/null &"); Otherwise, your shell itself (usually Bash) will attempt to execute it. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910818 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 thorpe, i am very glad to your help. Really appreciate that. last command you gave me didn't work. Well, redirecting ok but as i mention above. I have small sql script doesn't insert any record which means exec command not execute actually. And another point /usr/bin/php / is the same path for all linux servers ? Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910823 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 /usr/bin/php / is the same path for all linux servers ? No, but its pretty common. command -v php will show you where php is installed. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910829 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 please forgive my ignorance how to use that command ? <?php echo command -v php ?> Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910832 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 You need to type that at a shell prompt. Or php... echo system('command -v php'); if you don't have access. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910834 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 appear blank page... :confused: Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910837 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 command -v returns blank when nothing is found. So, your server may not have php's cli installed. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910841 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 command -v returns blank when nothing is found. So, your server may not have php's cli installed. Thank you very much thousands of times... Have any suggestion ? To run exec command without shebang. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910845 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 You can't exec any php if thats what your hoping. What exactly are you trying to do? Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910847 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 i am trying... Post data to (let's say) from form.php to insert.php. In insert.php(which has curl command previously i posted) going to test.php. Test.php is getting all records and put into a loop and send mail. But my problem is my hosting company allowed me to send 50 mails per 4 mins. So, when run loop i put a counter and if it reaches the 50 sleep(240); then get new smtp session send another 50 mails. Here i found some solution but not sure if it works or not 1 - insert.php create a file and write number of last record of DB and redirect to index.php 2 - run a cron job every 5 min. 3 - open text file, read it and compare the number with db last record ie: write 50 in text file and db has 51 records. So which means not equal and run loop. 4 - before run loop write new value into text file to prevent run same script again I will give a try to this way and hopefully works. I really appreciate for your help Regards Note : if you have a better idea, ready to listen and try it. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910852 Share on other sites More sharing options...
trq Posted September 2, 2009 Share Posted September 2, 2009 I would get a host that supports your requirements. Your not likely to find a reliable hack for this. Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910853 Share on other sites More sharing options...
sniperscope Posted September 2, 2009 Author Share Posted September 2, 2009 Thank you for your offer but i am in japan and my company prefer works with a japanese company. Because of communication problems Link to comment https://forums.phpfreaks.com/topic/172801-redirect-problem/#findComment-910854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.