pdo 与mysql 的有关问题,
程序员文章站
2024-01-27 14:55:40
...
pdo 与mysql 的问题,请教高手?
程序在window下正常,然而在linux下,
register:
public function Insert($input) {
$time = time ();
$sql = " INSERT INTO " . __DB_PREFIX__ . "member(
`email`,
`password`,
`secrecy_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 () ) );
}
}
这个方法好用,但是:
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 . "'";
//$sth = $this->prepare ( $sql );
//$sth->execute ();
$stmt = $this->prepare ( $sql );
if (! $stmt->execute ()) {
throw new Exception ( join ( ' ', $stmt->errorInfo () ) );
}
return ($stmt->rowCount () == 1) ? true : false;
}
}
这个法就不能用,为什么呢?
也就是说insert是可以的,但是用select 的时,就查不出来 了,在mysql 中用$sql这条语句测试是有结果的
请高手分析下,是什么原因导致的??
------解决方案--------------------
有没有报错呢?
------解决方案--------------------
程序在window下正常,然而在linux下,
register:
public function Insert($input) {
$time = time ();
$sql = " INSERT INTO " . __DB_PREFIX__ . "member(
`email`,
`password`,
`secrecy_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 () ) );
}
}
这个方法好用,但是:
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 . "'";
//$sth = $this->prepare ( $sql );
//$sth->execute ();
$stmt = $this->prepare ( $sql );
if (! $stmt->execute ()) {
throw new Exception ( join ( ' ', $stmt->errorInfo () ) );
}
return ($stmt->rowCount () == 1) ? true : false;
}
}
这个法就不能用,为什么呢?
也就是说insert是可以的,但是用select 的时,就查不出来 了,在mysql 中用$sql这条语句测试是有结果的
请高手分析下,是什么原因导致的??
------解决方案--------------------
有没有报错呢?
------解决方案--------------------
- PHP code
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 . "'"; //$sth = $this->prepare ( $sql ); //$sth->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]看看有结果不! return ($stmt->rowCount () == 1) ? true : false; } }
------解决方案--------------------
- PHP code
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 . "'"; //$sth = $this->prepare ( $sql ); //$sth->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; } }
------解决方案--------------------
- SQL code
$sql = "SELECT member_id FROM " . __DB_PREFIX__ . "member WHERE email=" . $name . " AND password'" . $password . "";
------解决方案--------------------
- SQL code
$sql = "SELECT member_id FROM " . __DB_PREFIX__ . "member WHERE email=" . $name . " AND password=" . $password ;相关文章
相关视频
上一篇: PHP截取中文字符串函数~包括GB2312和UT-8
下一篇: php页面加载时乱码,该如何解决
推荐阅读
-
iconv函数和mb_convert_encoding函数转码的有关问题
-
安装PHP可能遇到的问题“无法载入mysql扩展” 的解决方法_php技巧
-
PHP的实例化对象的成员变量有关问题
-
php中__destruct与register_shutdown_function执行的先后顺序问题,destruct
-
关于邮箱验证的有关问题,请高手帮忙看一下
-
关于readfile 和file_get_conents的有关问题
-
一个有关MYSQL的文章.E文的.MySQLs Query Cache
-
PHPExcel 向单元格插入图片就换行的有关问题
-
很简单的一个insert有关问题,但是就是有有关问题,请大家帮忙看看到底哪里有有关问题
-
关于C语言编程时字符缓冲的一些问题与解答