当前位置: 代码迷 >> PHP >> 请教小弟我这里加的对吗
  详细解决方案

请教小弟我这里加的对吗

热度:331   发布时间:2016-04-29 01:41:12.0
请问我这里加的对吗?
(intval(base64_decode($_GET[id])))"); 就是附近。。谢谢。

PHP code
<?phpif($_GET[id]){    $sql_1=mysql_query("select * from $tbname_jihua where id =(intval(base64_decode($_GET[id])))");}else{    $sql=mysql_query("select * from $tbname_jihua");}?>


------解决方案--------------------
字符串里包含的变量才被解析,函数名和常量不会被解析
PHP code
$id = intval(base64_decode($_GET[id]));$sql_1=mysql_query("select * from $tbname_jihua where id = {$id}");// or $sql_1=mysql_query("select * from $tbname_jihua where id = ". intval(base64_decode($_GET[id])) );
------解决方案--------------------
intval
base64_decode
都是php函数,就和上面说的。在字符串里面是无法解析的。
------解决方案--------------------
类似intval(base64_decode($_GET[id])) 这样的代码
单独写出来不好么,为什么要写在SQL里呢?因为省地方?

$id=intval(base64_decode($_GET[id]));
$sql_1=mysql_query("select * from $tbname_jihua where id ={$id}");

这样不清晰明了,而且你的问题也解决了...
  相关解决方案