Novice fopen function do not know where the wrong, the great God help to see

Source: Internet
Author: User
Tags php error
$DOCUMENT _root = $_server[' document_root ');
@ $fp = fopen ("$DOCUMENT _root/. /orders/orders.txt ", ' ab ');
Flock ($FP, LOCK_EX);
if (! $fp) {
echo "

submit failed ";
Exit
}


Always appears on page: Commit failed
Does that mean the file doesn't open?
I use
Echo $fp
Also meters have show anything


Reply to discussion (solution)

Put @ $fp = fopen in front of you, you can see the error message. If not, it may be that the error message has been turned off, to open the errors.

Put @ $fp = fopen in front of you, you can see the error message. If not, it may be that the error message has been turned off, to open the errors.


The great God has removed the error suppressor
and open the PHP error
There's still no hint.
There's just a "commit failure."

"$DOCUMENT _root/. /orders/orders.txt "
File exists?, print out? look.

I found the problem because the PHP built-in variable $_server[' Document_root ' should be written as $_server[document_root]
The two single quotes inside the brackets should not be added

No, the correct wording should be $_server[' document_root '],$_server[document_root]php also recognized, but the performance is not good.
You're sure it's just a change?
There should be a problem with the path to your file.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.