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 11 of 11

Thread: syntax error

  1. #1
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    syntax error

    <?php
    if($_SERVER[PHP_SELF]=="/include/profiles/index.inc.php")
    {
    header("Location: /index.php");
    exit;
    }

    $directory = getcwd();

    $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect.");
    $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");

    $sql = "SELECT * FROM $tbl_profiles WHERE directory = \"$directory\"";

    $result = @mysql_query($sql,$connection) or die("Couldn't execute profile query.");
    $num=mysql_num_rows($result);

    while ($row = mysql_fetch_array($result)) {

    $profile_id = $row['profile_id'];
    $dark_color = $row['dark_color'];
    $light_color = $row['light_color'];
    $panel_text = $row['panel_text'];
    $table_color = $row['table_color'];
    $font_color = $row['font_color'];
    $font_style = $row['font_style'];
    $font_size = $row['font_size'];
    $profile_url = $row['profile_url'];
    $page_name = $row['page_name'];
    $ratings = $row['ratings'];
    $p_name = $row['p_name'];
    $location = $row['location'];
    $gender = $row['gender'];
    $age = $row['age'];
    $marital = $row['marital'];
    $about_me = $row['about_me'];
    $hobbies = $row['hobbies'];
    // HP/MP/TP bars.
    $stathp = ceil($userrow['currenthp'] / $userrow 'maxhp' * 100);
    if ($userrow['maxmp'] != 0) { $statmp = ceil($userrow['currentmp'] / $userrow['maxmp'] * 100); } else { $statmp = 0; }
    $stattp = ceil($userrow["currenttp"] / $userrow["maxtp"] * 100);
    $stattable = "<table width=\"100\"><tr><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if ($stathp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if ($stathp < 66 && $stathp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if ($stathp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if ($statmp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if ($statmp < 66 && $statmp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if ($statmp < 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if ($stattp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if ($stattp < 66 && $stattp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if ($stattp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td>\n";
    $stattable .= "</tr><tr><td>HP</td><td>MP</td><td>TP</td></tr></table>\n";
    $userrow["statbars"] = $stattable;

    // Now make numbers stand out if they're low.
    if ($userrow["currenthp"] <= ($userrow["maxhp"]/5)) { $userrow["currenthp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currenthp"]."*</b></span></blink>"; }
    if ($userrow["currentmp"] <= ($userrow["maxmp"]/5)) { $userrow["currentmp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currentmp"]."*</b></span></blink>"; }

    $spellquery = doquery("SELECT id,name,type FROM `members`","spells");
    $userspells = explode(",",$userrow["spells"]);
    $userrow["magiclist"] = "";
    while ($spellrow = mysql_fetch_array($spellquery)) {
    $spell = false;
    foreach($userspells as $a => $b) {
    if ($b == $spellrow["id"] && $spellrow["type"] == 1) { $spell = true; }
    }
    if ($spell == true) {
    $userrow["magiclist"] .= "<a href=\"index.php?do=spell:".$spellrow["id"]."\">".$spellrow["name"]."</a><br />";
    }
    }
    if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None";
    }
    }

    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Please wrap PHP codes using the PHP tag
    PHP Code:
    <?php
    if($_SERVER[PHP_SELF]=="/include/profiles/index.inc.php")
    {
    header("Location: /index.php");
    exit;
    }

    $directory getcwd();

    $connection = @mysql_connect("$db_host""$db_user""$db_pass") or die("Couldn't connect.");
    $db = @mysql_select_db($db_name$connection) or die("Couldn't select database.");

    $sql "SELECT * FROM $tbl_profiles WHERE directory = \"$directory\"";

    $result = @mysql_query($sql,$connection) or die("Couldn't execute profile query.");
    $num=mysql_num_rows($result);

    while (
    $row mysql_fetch_array($result)) {

    $profile_id $row['profile_id'];
    $dark_color $row['dark_color'];
    $light_color $row['light_color'];
    $panel_text $row['panel_text'];
    $table_color $row['table_color'];
    $font_color $row['font_color'];
    $font_style $row['font_style'];
    $font_size $row['font_size'];
    $profile_url $row['profile_url'];
    $page_name $row['page_name'];
    $ratings $row['ratings'];
    $p_name $row['p_name'];
    $location $row['location'];
    $gender $row['gender'];
    $age $row['age'];
    $marital $row['marital'];
    $about_me $row['about_me'];
    $hobbies $row['hobbies'];
    // HP/MP/TP bars.
    $stathp ceil($userrow['currenthp'] / $userrow 'maxhp' 100);
    if (
    $userrow['maxmp'] != 0) { $statmp ceil($userrow['currentmp'] / $userrow['maxmp'] * 100); } else { $statmp 0; }
    $stattp ceil($userrow["currenttp"] / $userrow["maxtp"] * 100);
    $stattable "<table width=\"100\"><tr><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if (
    $stathp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if (
    $stathp 66 && $stathp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if (
    $stathp 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if (
    $statmp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if (
    $statmp 66 && $statmp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if (
    $statmp 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if (
    $stattp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if (
    $stattp 66 && $stattp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if (
    $stattp 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td>\n";
    $stattable .= "</tr><tr><td>HP</td><td>MP</td><td>TP</td></tr></table>\n";
    $userrow["statbars"] = $stattable;

    // Now make numbers stand out if they're low.
    if ($userrow["currenthp"] <= ($userrow["maxhp"]/5)) { $userrow["currenthp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currenthp"]."*</b></span></blink>"; }
    if (
    $userrow["currentmp"] <= ($userrow["maxmp"]/5)) { $userrow["currentmp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currentmp"]."*</b></span></blink>"; }

    $spellquery doquery("SELECT id,name,type FROM `members`","spells");
    $userspells explode(",",$userrow["spells"]);
    $userrow["magiclist"] = "";
    while (
    $spellrow mysql_fetch_array($spellquery)) {
    $spell false;
    foreach(
    $userspells as $a => $b) {
    if (
    $b == $spellrow["id"] && $spellrow["type"] == 1) { $spell true; }
    }
    if (
    $spell == true) {
    $userrow["magiclist"] .= "<a href=\"index.php?do=spell:".$spellrow["id"]."\">".$spellrow["name"]."</a><br />";
    }
    }
    if (
    $userrow["magiclist"] == "") { $userrow["magiclist"] = "None";
    }
    }

    ?>
    and give exact error and the line number
    Last edited by abduraooft; 03-16-2008 at 11:29 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    35
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Greetings comrade. Your problem is such:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fatman/public_html/test/syntax.php on line 39

    Now that means the problem can be found near line 39 (probably the $userrow array missing square brackets around its key):

    Code:
    $stathp = ceil($userrow['currenthp'] / $userrow 'maxhp' * 100);
    As a suggestion I would recommend enabling error reporting via error_reporting(E_ALL) at the beginning of your script when you have a problem.

  • #4
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    <php
    // HP/MP/TP bars.
    $stathp = ceil($userrow['currenthp'] / $userrow 'maxhp' * 100);
    if ($userrow['maxmp'] != 0) { $statmp = ceil($userrow ['currentmp'] / $userrow['maxmp'] * 100); } else { $statmp = 0; }
    $stattp = ceil($userrow["currenttp"] / $userrow["maxtp"] * 100);
    $stattable = "<table width=\"100\"><tr><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if ($stathp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if ($stathp < 66 && $stathp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if ($stathp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stathp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if ($statmp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if ($statmp < 66 && $statmp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if ($statmp < 33) { $stattable .= "<div style=\"padding:0px; height:".$statmp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td><td width=\"33%\">\n";
    $stattable .= "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"padding:0px; width:15px; height:100px; border:solid 1px black; vertical-align:bottom;\">\n";
    if ($stattp >= 66) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_green.gif);\"><img src=\"images/bars_green.gif\" alt=\"\" /></div>"; }
    if ($stattp < 66 && $stattp >= 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_yellow.gif);\"><img src=\"images/bars_yellow.gif\" alt=\"\" /></div>"; }
    if ($stattp < 33) { $stattable .= "<div style=\"padding:0px; height:".$stattp."px; border-top:solid 1px black; background-image:url(images/bars_red.gif);\"><img src=\"images/bars_red.gif\" alt=\"\" /></div>"; }
    $stattable .= "</td></tr></table></td>\n";
    $stattable .= "</tr><tr><td>HP</td><td>MP</td><td>TP</td></tr></table>\n";
    $userrow["statbars"] = $stattable;

    // Now make numbers stand out if they're low.
    if ($userrow["currenthp"] <= ($userrow["maxhp"]/5)) { $userrow["currenthp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currenthp"]."*</b></span></blink>"; }
    if ($userrow["currentmp"] <= ($userrow["maxmp"]/5)) { $userrow["currentmp"] = "<blink><span class=\"highlight\"><b>*".$userrow["currentmp"]."*</b></span></blink>"; }

    $spellquery = doquery("SELECT id,name,type FROM `members`","spells");
    $userspells = explode(",",$userrow["spells"]);
    $userrow["magiclist"] = "";
    while ($spellrow = mysql_fetch_array($spellquery)) {
    $spell = false;
    foreach($userspells as $a => $b) {
    if ($b == $spellrow["id"] && $spellrow["type"] == 1) { $spell = true; }
    }
    if ($spell == true) {
    $userrow["magiclist"] .= "<a href=\"index.php?do=spell:".$spellrow["id"]."\">".$spellrow["name"]."</a><br />";
    }
    }
    if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None";
    }
    }

    ?>
    only this part of the script does have errors .
    How can i change this line ?
    $stathp = ceil($userrow['currenthp'] / $userrow 'maxhp' * 100); ?
    My error is Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /index.inc.php on line 39

  • #5
    New Coder
    Join Date
    Mar 2008
    Posts
    35
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Code:
    $stathp = ceil($userrow['currenthp'] / $userrow 'maxhp' * 100);

    Code:
    $stathp = ceil($userrow['currenthp'] / $userrow['maxhp'] * 100);

  • #6
    New Coder
    Join Date
    Mar 2008
    Posts
    35
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Crime.

  • #7
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Warning: Division by zero in /index.inc.php on line 39

    Warning: Division by zero in /index.inc.php on line 41

    Fatal error: Call to undefined function doquery() in index.inc.php on line 65

  • #8
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    how can i enable error reporting via error_reporting(E_ALL) ?

  • #9
    New Coder
    Join Date
    Mar 2008
    Posts
    35
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Mihai View Post
    Warning: Division by zero in /index.inc.php on line 39
    On line 39 $userrow['maxhp'] is 0. This is a probelm. Find out where $userrow is defined ( I don't see it anywhere in your script).

    PHP Code:
    $stathp ceil($userrow['currenthp'] / $userrow['maxhp'] * 100); 

    Quote Originally Posted by Mihai View Post
    Warning: Division by zero in /index.inc.php on line 41
    On line 41 $userrow['maxhp'] is 0. This is a probelm. Find out where $userrow is defined ( I don't see it anywhere in your script).

    PHP Code:
    $stattp ceil($userrow["currenttp"] / $userrow["maxtp"] * 100); 

    Quote Originally Posted by Mihai View Post
    Fatal error: Call to undefined function doquery() in index.inc.php on line 65
    The doquery() function is never defined. Either a) Define it or b) Include it.

  • #10
    New Coder
    Join Date
    Mar 2008
    Posts
    35
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Mihai View Post
    how can i enable error reporting via error_reporting(E_ALL) ?
    If you're seeing stuff like

    Warning: Division by zero in /index.inc.php on line 39

    Warning: Division by zero in /index.inc.php on line 41

    Fatal error: Call to undefined function doquery() in index.inc.php on line 65
    then it is enabled.

    The warnings and errors are pretty helpful. If it says "Problem at line 39," go to line 39 and figure it out.

  • #11
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Please remember to read the stickies for this forum. In particular the one about using [php][/php] tags when posting code.


  •  

    Posting Permissions

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