For more information about pdo and mysql, how can this problem be solved? The program is normal in the window, but in linux, register: publicfunctionInsert ($ input) {$ timetime (); $ SQL & quot; INSERTINTO & quot ;. _ DB_PREFIX __. & quot; member (for questions about pdo and mysql, how can this problem be solved?
The program works normally in windows, but in linux,
Register:
Public function Insert ($ input ){
$ Time = time ();
$ SQL = "INSERT INTO". _ DB_PREFIX _. "member (
'Email ',
'Password ',
'Secret _ email ',
'Lock ',
'Add _ time ',
'Last _ login_time'
) VALUES (
'". $ Input ['name']."',
'". Md5 ($ input ['password'])."',
'". $ Input ['email']." ',
0,
". $ Time .",
". $ Time ."
)";
$ Stmt = $ this-> prepare ($ SQL );
If (! $ Stmt-> execute ()){
Throw new Exception (join ('', $ stmt-> errorInfo ()));
}
}
This method is easy to use,:
Public function Account ($ name, $ password ){
$ SQL = "select member_id from gm_member where email = 'mygirl 'and password = '25d55ad283aa400af464c76d713c07ad '";
// $ SQL = "SELECT member_id FROM ". _ DB_PREFIX __. "member WHERE email = '". $ name. "'AND password = '". $ password. "'";
// $…… = $ This-> prepare ($ SQL );
// $ Something-> execute ();
$ Stmt = $ this-> prepare ($ SQL );
If (! $ Stmt-> execute ()){
Throw new Exception (join ('', $ stmt-> errorInfo ()));
}
Return ($ stmt-> rowCount () = 1 )? True: false;
}
}
This method cannot be used. why?
That is to say, the insert statement is acceptable, but it cannot be found when the select statement is used. in mysql, the $ SQL statement is used for testing.
What causes the problem ??
------ Solution --------------------
Are there any errors?
------ Solution --------------------
PHP code
Public function Account ($ name, $ password) {$ SQL = "select member_id from gm_member where email = 'mygir' and password = '25d55ad283aa400af464c76d713c07ad '"; // $ SQL = "SELECT member_id FROM ". _ DB_PREFIX __. "member WHERE email = '". $ name. "'AND password = '". $ password. "'"; // $ Something = $ this-> prepare ($ SQL); // $ Something-> execute (); $ stmt = $ this-> prepare ($ SQL); if (! $ Stmt-> execute () {throw new Exception (join ('', $ stmt-> errorInfo ()));} [color = # FF0000] $ result = $ stmt-> fetch (PDO_FETCH_ASSOC); print_r ($ result); [/color] check if any result is returned! Return ($ stmt-> rowCount () = 1 )? True: false ;}}
------ Solution --------------------
PHP code
Public function Account ($ name, $ password) {$ SQL = "select member_id from gm_member where email = 'mygir' and password = '25d55ad283aa400af464c76d713c07ad '"; // $ SQL = "SELECT member_id FROM ". _ DB_PREFIX __. "member WHERE email = '". $ name. "'AND password = '". $ password. "'"; // $ Something = $ this-> prepare ($ SQL); // $ Something-> execute (); $ stmt = $ this-> prepare ($ SQL); if (! $ Stmt-> execute () {throw new Exception (join ('', $ stmt-> errorInfo ()));} $ result = $ stmt-> fetch (PDO_FETCH_ASSOC); print_r ($ result); return ($ stmt-> rowCount () = 1 )? True: false ;}}
------ Solution --------------------
SQL code
$ SQL = "SELECT member_id FROM". _ DB_PREFIX _. "member WHERE email =". $ name. "AND password'". $ password ."";
------ Solution --------------------
SQL code
$sql = "SELECT member_id FROM " . __DB_PREFIX__ . "member WHERE email=" . $name . " AND password=" . $password ;