Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Syntax help

  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts

    Syntax help

    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.

    PHP Code:
    $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 />"
    Last edited by ptmuldoon; 02-21-2007 at 11:29 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

    http://us3.php.net/manual/en/language.types.string.php

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    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

    PHP Code:
    $sql "SELECT * FROM gamelog ORDER BY {$sort} {$order}"

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    It goes in between the SELECT and the ORDER BY.

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

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    And yet again I'm struggling to get syntax right. Could someone give a hand and tell me whats wrong with this query?

    PHP Code:
    $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
    Last edited by ptmuldoon; 03-23-2007 at 01:44 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •