Maracles Posted April 10, 2009 Share Posted April 10, 2009 Hi, there is already a similar thread on this forums at at the following link however the solution here did not work for me: http://www.phpfreaks.com/forums/index.php?topic=223119.0 I was getting same error code as above until I finally found a spelling mistake and now I get the 'Your order could not be processed at this time. Please try again later.' which means that there is an error somewhere but I don't know how to tell what exactly it is or fix it. The book I'm learning from (PHP and MySQL Web Development - L. Welling) hints it may be a permissions thing but offers no recommendations for fixing it. My code is below: // open file for appending @ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab'); flock($fp, LOCK_EX); if (!$fp) { echo "<p><strong>Your order could not be processed at this time. Please try again later.</strong></p></body</html>"; exit; } fwrite ($fp, $outputstring, strlen($outputstring)); flock($fp, LOCK_UN); fclose($fp); echo "<p>Order written.</p>"; Any help is much appreciated Link to comment https://forums.phpfreaks.com/topic/153562-solved-warning-flock-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
Mark Baker Posted April 10, 2009 Share Posted April 10, 2009 Set the error level and reporting, then remove the @ from @ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab'); The @ suppresses any errors, so if your file cannot be opened, the first you know about it is when the flock() gives you this error. Fix the problem in the fopen() Link to comment https://forums.phpfreaks.com/topic/153562-solved-warning-flock-expects-parameter-1-to-be-resource/#findComment-806913 Share on other sites More sharing options...
Maracles Posted April 10, 2009 Author Share Posted April 10, 2009 Thank you for your reply. What do you mean by 'set the error level and reporting'? I have removed the @ however this has not made a differance. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/153562-solved-warning-flock-expects-parameter-1-to-be-resource/#findComment-806916 Share on other sites More sharing options...
Maracles Posted April 10, 2009 Author Share Posted April 10, 2009 Ooops, I have just noticed your signature. Where do I put that code, at the top of the actual php file I have the error in? Link to comment https://forums.phpfreaks.com/topic/153562-solved-warning-flock-expects-parameter-1-to-be-resource/#findComment-806918 Share on other sites More sharing options...
Maracles Posted April 10, 2009 Author Share Posted April 10, 2009 I added that to my script and ran it again. I got the following error below. I then created the directory on my server itself and ran the script again and it worked. Does this mean that there are insufficient permissions for the script to create directory itself? If so how can I change this? Thank you for your help, was stuck on this for quite a while!! Notice: Undefined variable: date in /homepages/36/d271495301/htdocs/Websites/ChimEnt/phpdev/chap1/processorder.php on line 109 Warning: fopen(/kunden/homepages/36/d271495301/htdocs/Websites/ChimEnt/../orders/orders.txt) [function.fopen]: failed to open stream: No such file or directory in /homepages/36/d271495301/htdocs/Websites/ChimEnt/phpdev/chap1/processorder.php on line 115 Warning: flock(): supplied argument is not a valid stream resource in /homepages/36/d271495301/htdocs/Websites/ChimEnt/phpdev/chap1/processorder.php on line 118 Your order could not be processed at this time. Please try again later. Link to comment https://forums.phpfreaks.com/topic/153562-solved-warning-flock-expects-parameter-1-to-be-resource/#findComment-806919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.