Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

unexpected T_String

  • 07-04-2012 2:41pm
    #1
    Registered Users, Registered Users 2 Posts: 459 ✭✭


    I'm just not quite savvy enough yet to spot what's wrong with this syntax - help much appreciated

    At the first if statement I'm getting a Parse error: syntax error, unexpected T_STRING error.

    What is wrong with my syntax please?
    [PHP]<?php

    $findPage[page_info] = preg_replace("/username/", "/$display_name/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/timestamp/", "/$timestamp2/", "/$findPage[page_info])/");
    $findPage[page_info] = preg_replace("/points/", "/$points/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/gamename/", "/$gameName2/", ""/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/gameid/", "/$game/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/hungerlevel/", "/$hungerLevel/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/pointsname/", "/$pointVar/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/usersonline/", "/$countUsersOn/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/totalusers/", "/$numMembers/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/activepetID/", "/$activePetID/", "/$findPage[page_info]/");
    $findPage[page_info] = preg_replace("/activepet/", "/$activePetName/", "/$findPage[page_info]/");

    $findPage[page_info] = preg_replace("/activepetlvl/", "/$activePetLevel/", "/$findPage[page_info]/");

    if (!$getInfo2[real_name]) { $getInfo2[real_name] = "Unknown Name"; }
    $findPage[page_info] = preg_replace("/realname/", "/$pointVar/", "/$findPage[page_info])/";

    if ($getInfo2[gender] == 2) { $gender = "<font color=blue><b>Male</b></font>"; }
    if ($getInfo2[gender] == 1) { $gender = "<font color=#FF0099><b>Female</b></font>"; }
    if ($getInfo2[gender] == 0) { $gender = "Undecided"; }
    $findPage[page_info] = preg_replace("/gender/", "$gender", $findPage[page_info])/";

    smilies($findPage[page_info]);

    ?>[/PHP]


Comments

  • Closed Accounts Posts: 249 ✭✭OneIdea


    Try this maybe?
    [PHP]
    <?php

    $findPage[page_info] = preg_replace('#username#', '$display_name', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#timestamp#', '$timestamp2', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#points#', '$points', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#gamename#', '$gameName2', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#gameid#', '$game', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#hungerlevel#', '$hungerLevel', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#pointsname#', '$pointVar', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#usersonline#', '$countUsersOn', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#totalusers#', '$numMembers', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#activepetID#', '$activePetID', $findPage[page_info]);
    $findPage[page_info] = preg_replace('#activepet#', '$activePetName', $findPage[page_info]);

    $findPage[page_info] = preg_replace('#activepetlvl#', '$activePetLevel', $findPage[page_info]);

    if (empty($getInfo2[real_name])) { // I added here what I think you wanted?
    $getInfo2[real_name] = "Unknown Name";
    }

    $findPage[page_info] = preg_replace('#realname#', '$pointVar', $findPage[page_info]);

    if ($getInfo2[gender] == 2) { $gender = '<font color="blue"><b>Male</b></font>'; }
    if ($getInfo2[gender] == 1) { $gender = '<font color="#FF0099"><b>Female</b></font>'; }
    if ($getInfo2[gender] == 0) { $gender = "Undecided"; }
    $findPage[page_info] = preg_replace('#gender#', '$gender', $findPage[page_info]);

    smilies($findPage[page_info]);

    ?>
    [/PHP]


  • Registered Users, Registered Users 2 Posts: 1,657 ✭✭✭komodosp


    not sure, but $ is a reserved character for regular expressions, so I'm not sure about using them as variable names in strings for preg_replace...


  • Closed Accounts Posts: 249 ✭✭OneIdea


    komodosp wrote: »
    not sure, but $ is a reserved character for regular expressions, so I'm not sure about using them as variable names in strings for preg_replace...

    Emm the OP isn't using variables in the pattern. See preg_replace. The single quotes around the replacement value, could possible be removed as well.

    So although the code above should work, you could also try this one:[PHP]
    <?php

    $findPage[page_info] = preg_replace('#username#', $display_name, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#timestamp#', $timestamp2, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#points#', $points, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#gamename#', $gameName2, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#gameid#', $game, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#hungerlevel#', $hungerLevel, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#pointsname#', $pointVar, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#usersonline#', $countUsersOn, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#totalusers#', $numMembers, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#activepetID#', $activePetID, $findPage[page_info]);
    $findPage[page_info] = preg_replace('#activepet#', $activePetName, $findPage[page_info]);

    $findPage[page_info] = preg_replace('#activepetlvl#', $activePetLevel, $findPage[page_info]);

    if (empty($getInfo2[real_name])) { // I added here what I think you wanted?
    $getInfo2[real_name] = "Unknown Name";
    }

    $findPage[page_info] = preg_replace('#realname#', $pointVar, $findPage[page_info]);

    if ($getInfo2[gender] == 2) { $gender = '<font color="blue"><b>Male</b></font>'; }
    if ($getInfo2[gender] == 1) { $gender = '<font color="#FF0099"><b>Female</b></font>'; }
    if ($getInfo2[gender] == 0) { $gender = "Undecided"; }
    $findPage[page_info] = preg_replace('#gender#', $gender, $findPage[page_info]);

    smilies($findPage[page_info]);

    ?>
    [/PHP]


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    You've also got double quotes on this line:

    $findPage[page_info] = preg_replace("/gamename/", "/$gameName2/", ""/$findPage[page_info]/");


Advertisement