开发者

php code consolidation

开发者 https://www.devze.com 2023-04-04 01:47 出处:网络
I was troubleshooting some code and ended up with this: $url=$this->_protected_arr[\'f3b\']; $title=$this->_protected_arr[\'f3a\'];

I was troubleshooting some code and ended up with this:

$url=$this->_protected_arr['f3b'];
$title=$this->_protected_arr['f3a'];
$email=$_SESSION['email'];
database::query("INSERT INTO bo VALUES ('$title','$url','','$email')");

I think that it should be abe开发者_如何转开发l to get rid of $url, $title, and $email and just insert their values directly into the query. How do I write this in a single statement?


Like this:

database::query("INSERT INTO bo VALUES ('{$this->_protected_arr[f3b]}', '{$this->_protected_arr[f3a]}', '', '$_SESSION[email]')");

Be sure that everything is properly escaped for the SQL query.


database::query("INSERT INTO bo VALUES ('"
                . $this->_protected_arr[f3b] . "', '"
                . $this->_protected_arr[f3a] . "', '', '"
                . $_SESSION[email]."')");
0

精彩评论

暂无评论...
验证码 换一张
取 消