AI编程助手
AI免费问答

php文件中的sql的分割问题

  2016-06-23 14:10   1284浏览 原创

$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!!!!

php免费学习视频:立即学习
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。