开发者

php code consolidation

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜