The where condition of thinkphp cannot be used as an array.

Source: Internet
Author: User
The where condition of thinkphp cannot use an array. if I write the analysis result like this, I can query the data: $ admin_data = $ admin-> where ('username = "'. $ username. '"')-> find ();
In this case, the webpage "cannot display this webpage": $ admin_data = $ admin-> where (array ('username' => $ username)-> find ();
Analyze the cause.
1. the thinkphp version is 3.13.
2. it is the testing code, regardless of other code interference.


Reply to discussion (solution)

PHP: 5.2
I uninstalled IIS on the machine a few days ago.

$ Arr ['username'] => $ username;
$ Admin_data = $ admin-> where ($ arr)-> find ();
Try

$ Arr ['username'] = $ username;
$ Admin_data = $ admin-> where ($ arr)-> find ();
Try

$ Ar = "username = 'yourname '";
Echo is_array ($ ar );

The first input is not an array, but a string.

$ Arr ['username'] = $ username;
$ Admin_data = $ admin-> where ($ arr)-> find ();
Try


Or not.

The first input is not an array, but a string.


Maybe I didn't express it clearly. I mean, in the where clause, it is normal to query in the string form. in the array form, "this webpage cannot be displayed"

Let's take a look at the parameters received in the find () method ??

What is the type of the username field?

Check the thinkPHP running record to see what is wrong, or manually enter a new php file. Some errors are terrible,

$ Admin_data = $ admin-> query ("select * from hao_admin ");
$ Admin_data = $ admin-> where (array ('username' => $ username)-> find ();

The first type of query is normal with data.
The second type of query is "this page cannot be displayed ".

View apache error logs:
PHP Warning: Directive 'register _ globals' is no longer supported in PHP 6 and greater in Unknown on line 0
PHP Warning: Directive 'register _ long_arrays 'is no longer supported in PHP 6 and greater in Unknown on line 0
PHP Warning: Directive 'Magic _ quotes_gpc 'is no longer supported in PHP 6 and greater in Unknown on line 0
I have read logs before, but I don't pay too much attention to these errors.

The PHP version is PHP6.0.0 through phpinfo. After PHP5.2.6 is reinstalled, OK.

Is there such a thing?

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.