我在发布之前搜索过,但没有找到我的问题的答案。在MYSQL中使用PHP变量存储查询
我具有其中存储的查询,如(与存储在数据库中的PHP变量)的数据库中的表:
select * from accounts where type = 'client'
select * from accounts where user_id = $userid
select * from accounts where name = '$name'
我假定当我把该特定查询从数据库PHP将识别该变量并将其替换,但将其视为常规文本。
有没有办法让PHP替换存在的实际变量$ _ _?我想也许eval()函数可能是?
您从哪里执行脚本?为PHP变量工作,你应该执行你的SQL语句在PHP脚本 – 2012-04-24 17:12:42
类似的问题:http://stackoverflow.com/questions/283222/best-way-to-substitute-variables-in-plain-text-using-php – Trevor 2012-04-24 17:13:48