View Full Version : Syntax help

02-22-2007, 12:21 AM
If there is one thing I seem to struggle with is when to use single vs double quotes in syntax. In the below line of code, I'm trying to get the appropriate player color into the a log entry.

I have the variables $plr_color and $op_color defined earlier as their color. But the log is only giving me a regular, white text.

Edit: Nevermind. It does work. Quess it helps if I place the variables earlier in the right place, and not inside an if statement.

$gamelog = $timestamp ." - <strong class=\"$plr_color\"> " .$_SESSION['player_name']."</strong> attacked ".$_SESSION['STATES'][$to_country]['name']." from ".$_SESSION['STATES'][$from_country]['name']." and conquered it from <strong class=\"$op_color\"> ".$op_ply_name."</strong><hr />";

02-22-2007, 12:37 AM
I see you fixed your problem, but I thought I'd share a link with you that does a good job of explaining the differences between single quotes and double quotes. It's from the PHP manual actually, and cleared a lot up for me when I read through it.


02-28-2007, 03:05 AM
Thanks for the link, and its pretty helpful.

Yet, I still seem to be struggling with an adding a WHERE field = yes to the end of this query

$sql = "SELECT * FROM gamelog ORDER BY {$sort} {$order}";

02-28-2007, 05:58 AM
It goes in between the SELECT and the ORDER BY.

$sql = "SELECT * FROM gamelog WHERE field = 'yes' ORDER BY {$sort} {$order}";

03-23-2007, 01:59 AM
And yet again I'm struggling to get syntax right. Could someone give a hand and tell me whats wrong with this query?

$sql = "SELECT adjacencies FROM {$table} WHERE id = {$from_country} ";

Edit: Nevermind. It wasn't the query, but rather pulling the wrong field from the $table

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum