I am working with some SQL.
Curly braces fixes things in a query.

I have these 2 types of objects:
$this->subject
and
$this->sess->userid

My question is, why does the first work well?
But the second longer type needs curly braces around?

VALUES ( '$this->subject', '$message', {$this->sess->userid}, '{$this->sess->username}', $time );

    None of this has anything at all to do with SQL.

    You're talking about the way PHP parses strings and variables within those strings. You're also using the wrong (and dangerous) approach to build a SQL query in PHP - look into PDO or Mysqli and prepared statements.

      Thanks.
      So, it has nothing to do with SQL.
      This means I posted in the wrong forum ....

      I actually use PDO for everything regarding database.
      Because of the great connection possibility to different databases.

      But this time I do not use prepare-bindparam-execute.
      I am willing to take the riscue to work without prepare.

        halojoy;11064561 wrote:

        I am willing to take the riscue to work without prepare.

        That's great, but are your users willing to take that risk?

          Thanks Nog Dog.
          Many good examples!

          maxxd.
          Well, I might reconsider using PDO prepare.
          I know your advice is the most correct one.

            Write a Reply...