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 ....