user656925
user656925

Reputation:

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 abel 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?

Upvotes: 0

Views: 91

Answers (2)

472084
472084

Reputation: 17885

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

Upvotes: 1

Kerrek SB
Kerrek SB

Reputation: 477060

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.

Upvotes: 1

Related Questions