当前位置: 代码迷 >> PHP >> php文件中的sql的分割有关问题
  详细解决方案

php文件中的sql的分割有关问题

热度:168   发布时间:2013-06-19 10:26:41.0
php文件中的sql的分割问题
$query='Select * from authorized_users where name= "'.$userid.'" and password=sha1("'.$password.'")';
这样写对吗?

------解决方案--------------------
字符串是用单引号括起来的
------解决方案--------------------
引用:
$query='Select * from authorized_users where name= "'.$userid.'" and password=sha1("'.$password.'")';
这样写对吗?



$query="Select * from authorized_users where name= '$userid' and password='{sha1($password)}'";
------解决方案--------------------
$query='Select * from authorized_users where name= "'.$userid.'" and password=sha1("'.$password.'")';
语法正确,但可读性不强

$query="Select * from authorized_users where name='$userid' and password=sha1('$password')";
这样是不是清爽些?
  相关解决方案