Pay attention to SQL queries in cities

Source: Internet
Author: User
Note Notice where SQL queries exist: the Useofundefinedconstantmytime-assumedmytimeinvarwwwhtmlcalsncalresult.phponline15 appears this is the last line (15 rows) $ query & quot; select * fromempoloyeewhe where SQL queries have a note

Notice: Use of undefined constant mytime-assumed 'mytime' in/var/www/html/calsn/calresult. php on line 15
This is the last line (15 rows)
$ Query = "select * from empoloyee where empid = '$ empid '";
$ Result = mysql_query ($ query) or die (mysql_error ());
$ Num = mysql_num_rows ($ result );
If ($ num> 0)
{
$ Row = mysql_fetch_array ($ result );
$ Mytime = $ row [mytime];

------ Solution --------------------
$ Row [mytime]

No quotation marks?
------ Solution --------------------
Yes. The key name must be enclosed in quotation marks.
------ Solution --------------------
Use of undefined constant mytime

A non-defined constant is used. if mytime in $ row [mytime] is not enclosed in quotation marks, php will be treated as a constant by default. if the constant cannot be found, it will be treated as a string, however, at the same time, a Notice prompt will still be thrown. although the effect is not big, the logic is indeed a little different. The performance is slightly affected by the way of thinking (although the performance does not matter)
------ Solution --------------------
$ Mytime = $ row ['mytime'];

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.