Reputation: 378
I'm trying to concat $_SESSION["username"]
with $q
. I've tried several ways but can't seem to concat the two.
Attempts
VALUES ('".$_SESSION["username"] + $q."', '".$_SESSION["username"]."', '$q')
VALUES ('".$_SESSION["username"]." + $q', '".$_SESSION["username"]."', '$q')
VALUES ('".$_SESSION["username"]. + $q"', '".$_SESSION["username"]."', '$q')
I've looked up string operators but I think the syntax is slightly different with the $_SESSION[]
variable.
http://php.net/manual/en/language.operators.string.php
Upvotes: 0
Views: 857
Reputation: 7465
Use the dot operator to concatenate strings in PHP:
VALUES ('" .$_SESSION["username"] . $q . "', '" .$_SESSION["username"]. "', '$q')
Note that your code is subject to SQL injection.
Upvotes: 1