Why is the SQL query code blank in php?

Source: Internet
Author: User
Why is the SQL query code blank in php? Why is this SQL query statement blank when it is put into php? The statement is no problem in mysql Query, and the query result can be displayed. $ SQL & nbsp; = & nbsp; mysql_query ('select & nbsp; attach. * & nbsp;, & nbsp; category: Why is the SQL query code blank in php?
Why is this SQL query statement blank when it is put into php?
The statement is no problem in mysql Query, and the query result can be displayed.

$ SQL = mysql_query ('select attach. *, category. * from attach, category where attach. id = substring_index (substr (category. ext, locate ('"attach"', category. ext), '"', 4), '"',-1) order by rand () limit 5 ');

If you remove
Substring_index (substr (category. ext, locate ('"attach"', category. ext), '"', 4), '"',-1)
No problem. how can this problem be solved?

------ Solution --------------------
You have used unescaped single quotes in the string enclosed by single quotes. isn't it an error?

$ Sqlstr = <SQL
Select attach. *, category. * from attach, category where attach. id = substring_index (substr (category. ext, locate ('"attach"', category. ext), '"', 4), '"',-1) order by rand () limit 5
SQL;
$ SQL = mysql_query ($ sqlstr );

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.