Anomaly.

    Date: 03/17/07 (PHP Community)    Keywords: php, mysql, browser, database, sql

    I can't seem to figure out this problem for the life of me.

    The error is this: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /opt/lampp/htdocs/_projects/medievalbattles/current/v8_r3/httpdocs/access.php on line 139

    LIne 139 is: $servername = $row["alt_name"];

    Even if I comment out this entire portion of code, the error still exits (even after cleaning my entire browser cache and restarting my computer five times). I've tried cleaning my Smarty template cache, but that didn't help.

    	// was inevitable to requery this. maybe use memcached?
    $count = 1;
    $sql = "SELECT alt_name, databasename FROM ".$_MB->db_name.".servers";
    $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
    while ($row = mysql_fetch_assoc($res))
    {
    $server_name = $row["alt_name"];
    $server_database = $row["databasename"];

    $sql2 = "SELECT serverstart, tickstart, serverend, round FROM ".$server_database.".game_info";
    $res2 = mysql_query($sql2, $_MB->connection) or die(mysql_error());
    $row2 = mysql_fetch_assoc($res2);
    $time_data[$server_name]["serverstart"] = $row2["serverstart"];
    $time_data[$server_name]["tickstart"] = $row2["tickstart"];
    $time_data[$server_name]["serverend"] = $row2["serverend"];
    $time_data[$server_name]["round"] = $row2["round"];

    $count++;
    }


    Please help.

    $verifylogin = "yes";
    include("header.php");

    $sql = "SELECT name, prestige, rank, kills, verified FROM ".$_MB->db_name.".accounts WHERE id = '".$_SESSION["account_id"]."'";
    $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
    $row = mysql_fetch_assoc($res);
    $_SMARTY->assign("account_data", $row);

    //if ($user_verified != "y")
    //    $_MB->redirectuser("user_validate.php", "");

    if ($_SESSION["successful_reg"] == "1")
    {
        unset($_SESSION["successful_reg"]);
        unset($_SESSION["msg"]);
        $_SESSION["cdbname"] = $cdbname;
        $_SESSION["cloggedin"] = "yes";
        $_SESSION["loggedin"] = 1;

        header("Refresh: 5; game/overview.php");
        exit();    
    }
    else
    {
        $_SMARTY->assign("msg", $_MB->resultmessage());
        unset($_SESSION["msg"]);

        if ($_POST["login"])
        {
            $game = $_POST["game"];
            $_MB->use_db = $_POST["db"];
            $non_bar_clock = date("M d, y - h:ia");
            $clock = $_MB->month." ".$_MB->time;

            $sql = "SELECT id FROM ".$_MB->use_db.".users WHERE accountid = '".$_SESSION["account_id"]."'";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            if (mysql_num_rows($res))
            {
                $row = mysql_fetch_assoc($res);
                $userid = $row["id"];
           
                $sql = "SELECT tpw FROM ".$_MB->db_name.".servers WHERE id = '".$game."'";
                $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
                $row = mysql_fetch_assoc($res);
                    $ticks_per_week = $row["tpw"];
       
                $sql = "UPDATE ".$_MB->use_db.".user_aids SET timer = '".$ticks_per_week."' WHERE user_id = '".$userid."'";
                mysql_query($sql, $_MB->connection) or die(mysql_error());

                $sql = "UPDATE ".$_MB->use_db.".users SET online = 'y', lastlogin = '".$clock."'  WHERE id = '".$userid."'";
                mysql_query($sql, $_MB->connection) or die(mysql_error());

                $sql = "INSERT INTO ".$_MB->use_db.".user_online (id, userid, time, ip) VALUES ('', '".$userid."', '".$clock."', '".$_SERVER["REMOTE_ADDR"]."')";
                mysql_query($sql, $_MB->connection) or die(mysql_error());

                $_SESSION["cdbname"] = $_MB->use_db;
                $_SESSION["cloggedin"] = "yes";
                redirectuser("game/overview.php", "");
            }
            else
                redirectuser("access.php", "You do not have an empire on that server.");
        }

        if ($_POST["gameregistration"])
        {
            // Empire creation
            $game = $_POST["game"];
            $_MB->use_db = $_POST["db"];
            $sql = "SELECT * FROM ".$_MB->db_name.".servers WHERE id = '".$game."'";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            if (mysql_num_rows($res))
            {
                $sql = "SELECT * FROM ".$_MB->use_db.".users WHERE accountid = '".$_SESSION["account_id"]."'";
                $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
                if (!mysql_num_rows($res))
                {
                    $_SMARTY->assign("create_empire", TRUE);
                    $_SMARTY->assign("db", $_MB->use_db);
                    $_SMARTY->assign("game", $game);

                    $sql = "SELECT id, name FROM ".$_MB->db_name.".races ORDER BY name ASC";
                    $res =mysql_query($sql, $_MB->connection) or die(mysql_error());
                    $row = mysql_fetch_assoc($res);
                    $_SMARTY->assign("races", $row);

                    $sql = "SELECT id, name FROM ".$_MB->db_name.".classes ORDER BY name ASC";
                    $res =mysql_query($sql, $_MB->connection) or die(mysql_error());
                    $row = mysql_fetch_assoc($res);
                    $_SMARTY->assign("classes", $row);
                }
                else
                    redirectuser("access.php", "You already have an empire on that server.");
            }
        }
        else
        {
            $sql = "SELECT id, alt_name, databasename, gametype FROM ".$_MB->db_name.".servers";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            $row = mysql_fetch_assoc($res);
            $_SMARTY->assign("server_list", $row);

            // was inevitable to requery this. maybe use memcached?
            $count = 1;
            $sql = "SELECT id, alt_name, databasename, gametype FROM ".$_MB->db_name.".servers";
            $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
            while ($row = mysql_fetch_assoc($res))
            {
                $server_alt_name = $row["alt_name"];
                $_MB->use_db = $row["databasename"];

                $sql2  = "SELECT serveractive FROM ".$_MB->use_db.".game_info";
                $res2 =mysql_query($sql2, $_MB->connection) or die(mysql_error());
                $row2 = mysql_fetch_assoc($res2);
                    $server_data[$server_alt_name]["active"] = $row2["serveractive"];

                $sql2 = "SELECT empirename FROM ".$_MB->use_db.".users WHERE accountid = '".$_SESSION["account_id"]."'";
                $res2 =mysql_query($sql2, $_MB->connection) or die(mysql_error());
                $row2 = mysql_fetch_assoc($res2);
                    $server_data[$server_alt_name]["empire"] = $row2["empirename"];

    `            $count++;
            }

            $_SMARTY->assign("server_loop_max", $count);
            $_SMARTY->assign("server_data", $server_data);
        }

        $sql = "SELECT alt_name, databasename FROM ".$_MB->db_name.".servers";
        $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
        $_SMARTY->assign("server_time", mysql_fetch_assoc($res));   

        // was inevitable to requery this. maybe use memcached?
        $count = 1;
        $sql = "SELECT alt_name, databasename FROM ".$_MB->db_name.".servers";
        $res = mysql_query($sql, $_MB->connection) or die(mysql_error());
        while ($row = mysql_fetch_assoc($res))
        {
            $server_name = $row["alt_name"];
            $server_database = $row["databasename"];

            $sql2 = "SELECT serverstart, tickstart, serverend, round FROM ".$server_database.".game_info";
            $res2 = mysql_query($sql2, $_MB->connection) or die(mysql_error());
            $row2 = mysql_fetch_assoc($res2);
                $time_data[$server_name]["serverstart"] = $row2["serverstart"];
                $time_data[$server_name]["tickstart"] = $row2["tickstart"];
                $time_data[$server_name]["serverend"] = $row2["serverend"];
                $time_data[$server_name]["round"] = $row2["round"];

            $count++;
        }
           
        $_SMARTY->assign("time_loop_max", $count);
        $_SMARTY->assign("time_data", $time_data);
    }

    $_SMARTY->display("pages/access.tpl");

    include("footer.php");
    ?>

    Source: http://community.livejournal.com/php/552904.html

« Stupid Error || pop to mysql »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home