Home >Backend Development >PHP Tutorial >php文件中的sql的分割问题

php文件中的sql的分割问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:10:041182browse

$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')";
这样是不是清爽些?

你们说的对的,我是初学,结果表名写错了。sorry!!!!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn