Home > Backend Development > PHP Tutorial > 请教小弟我这里加的对吗

请教小弟我这里加的对吗

WBOY
Release: 2016-06-13 13:38:04
Original
852 people have browsed it

请问我这里加的对吗?
(intval(base64_decode($_GET[id])))"); 就是附近。。谢谢。

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php if($_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");
}
?>
Copy after login


------解决方案--------------------
字符串里包含的变量才被解析,函数名和常量不会被解析
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])) );
<br><font color="#e78608">------解决方案--------------------</font><br>intval<br>base64_decode<br>都是php函数,就和上面说的。在字符串里面是无法解析的。
<br><font color="#e78608">------解决方案--------------------</font><br>类似intval(base64_decode($_GET[id])) 这样的代码<br>单独写出来不好么,为什么要写在SQL里呢?因为省地方?<br><br>$id=intval(base64_decode($_GET[id]));<br>$sql_1=mysql_query("select * from $tbname_jihua where id ={$id}");<br><br>这样不清晰明了,而且你的问题也解决了... <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template