Or the blank question in the morning

Source: Internet
Author: User
The problem is that, for example, if you do not input anything in the input box, click submit and click it to print out "You haven't input yet". However, what I printed out is "NONE". I listened to others. I just want to change isset to trim. When I try to submit it empty, I can print "You haven't entered it "...

The problem is that, for example, if you do not input anything in the input box, click submit and click it to print out "You haven't input yet". However, what I printed out is "NONE". I listened to others. I just changed isset to trim. I tried to print out "You haven't input" when I open the empty commit, but the problem is that every time I open this page, I will report the error Notice: undefined index: num in D: wampwwwtest. why does php on line 13 look like this?
I tried to change it to empty. What should I do? What's more, the result I want is that when I open this page, No prompts are displayed, "no" or "You have not entered". Thank you.

      
      
  Prepare ("select * from aaa where num =? "); $ Stmt-> execute (array ($ _ POST ['num']); $ res = $ stmt-> fetchall (PDO: FETCH_ASSOC ); if ($ res) {foreach ($ res as $ v) {echo $ v ['name'] ;}} else {echo "no ";}} else {echo "You have not entered" ;}?>

Reply content:

The problem is that, for example, if you do not input anything in the input box, click submit and click it to print out "You haven't input yet". However, what I printed out is "NONE". I listened to others. I just changed isset to trim. I tried to print out "You haven't input" when I open the empty commit, but the problem is that every time I open this page, I will report the error Notice: undefined index: num in D: wampwwwtest. why does php on line 13 look like this?
I tried to change it to empty. What should I do? What's more, the result I want is that when I open this page, No prompts are displayed, "no" or "You have not entered". Thank you.

      
      
  Prepare ("select * from aaa where num =? "); $ Stmt-> execute (array ($ _ POST ['num']); $ res = $ stmt-> fetchall (PDO: FETCH_ASSOC ); if ($ res) {foreach ($ res as $ v) {echo $ v ['name'] ;}} else {echo "no ";}} else {echo "You have not entered" ;}?>

Because the POST data does not exist before you submit it, the error $ _ POST ['num'] does not exist. Just add @ to the front, or define POST as null first.

Different PHP versions cause different error levels. You can hide notice-level errors at the top entry:

error_reporting( error_reporting() & ~E_NOTICE )

I can't see it anymore.

If (empty ($ _ POST ['num']) {echo 'num not input ';}
Related Article

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.