Php query cannot output results

Source: Internet
Author: User
Php query cannot output result Action


Public function login (){

$ Name = $ _ POST ['name'];
$ Psw = $ _ POST ['pwd'];
$ Login1 = D ('login ');
$ AB = $ login1-> loginModel ($ name );
Echo $ AB;



Model


Public function loginModel ($ name ){
$ SQL = "SELECT * FROM userlogin where username = '$ name '";
$ Info = mysql_query ($ SQL );
$ A = mysql_fetch_array ($ info );
Return $;


Html


Reply to discussion (solution)

$ AB is an array, and echo is not acceptable. Print_r ($ AB); what do you get?

$ AB is an array, and echo is not acceptable. Print_r ($ AB); what do you get?



Still not output on the page

Are you sure the program enters the model? public function loginModel ($ name) {exit; // check whether the program can exit.

Are you sure the program enters the model? public function loginModel ($ name) {exit; // check whether the program can exit.

Entered
$ SQL = "SELECT * FROM userlogin where username = '$ name '";
Echo $ SQL;

SQL statement output on the page
SELECT * FROM userlogin where username = 'eeeee'

$ A = mysql_fetch_array ($ info );
Var_dump ($ a); // Paste the result

$ A = mysql_fetch_array ($ info );
Var_dump ($ a); // Paste the result

Bool (false)

That means there is no such record in your table.

When I run the SQL statement in the database, I can still find the value.

Php error prompt? Add the following sentence before executing the query.
Mysql_query ("set names utf8"); // if your table is gbk, change it to gbk.

Php error prompt? Add the following sentence before executing the query.
Mysql_query ("set names utf8"); // if your table is gbk, change it to gbk.


No effect. Is it because I wrote it wrong?

$ SQL = "SELECT * FROM userlogin where username = '$ name '";
Mysql_query ("set names utf8 ");
$ Info = mysql_query ($ SQL) or die (mysql_error ());
$ A = mysql_fetch_array ($ info );
Var_dump ($ );

What is the result and what is an error.



$ SQL = "SELECT * FROM userlogin where username = '$ name '";
Mysql_query ("set names utf8 ");
$ Info = mysql_query ($ SQL) or die (mysql_error ());
$ A = mysql_fetch_array ($ info );
Var_dump ($ );

What is the result and what is an error.

Add this or die (mysql_error (); the SELECT * FROM userlogin where username = ''Access denied for user 'odbc '@ 'localhost' (using password: NO) error is returned)

No connected database

Do you have the ODBC user? make sure the user and password are entered correctly.

My mysql has no password for the tp framework

No connected database

What should I do?

Do you have the ODBC user? If yes, are you authorized?

I can't do that either.

I don't know what the problem is, but I fixed it. I wrote it in another method and called it. I just needed to delete it and replace it with this ....

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.