Adding strings to a query statement?

I want to use my string $stringvar to show text in this sql query. ATM its sticking “$player, $score” into a field, I want it to instead print it out into the sql statement.

This is my code:
$stringvar="$player, $score";
$sql=mysql_query(“INSERT INTO $game_db VALUES (’$new_matchid’, ‘$opponent’, ‘$map’, $stringvar, ‘$result’)”);

This is what I want the sql query thing to look like:
$sql=mysql_query(“INSERT INTO $game_db VALUES (’$new_matchid’, ‘$opponent’, ‘$map’, $player, $score, ‘$result’)”);

and where is your problem?

You’re going to have to extract them using explode() or split() (whichever works best for you, see the manual) and put them separately into the query.

Looks to me by the code provided you missed some single quotes.

$stringvar needs them and so does $player and $score.

Unless I am missing something.

Sponsor our Newsletter | Privacy Policy | Terms of Service