Pdo and mysql problems,

Source: Internet
Author: User
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 ;

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.