Enjoy an ad free experience by logging in. Not a member yet?
Register .
03-16-2008, 10:10 AM
PM User |
#1
Regular Coder
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";
}
}
?>
03-16-2008, 10:25 AM
PM User |
#2
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 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
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
Last edited by abduraooft; 03-16-2008 at 10:29 AM ..
03-16-2008, 10:36 AM
PM User |
#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.
03-16-2008, 10:45 AM
PM User |
#4
Regular Coder
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
03-16-2008, 10:50 AM
PM User |
#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);
03-16-2008, 10:51 AM
PM User |
#6
New Coder
Join Date: Mar 2008
Posts: 35
Thanks: 0
Thanked 4 Times in 4 Posts
Crime.
03-16-2008, 10:57 AM
PM User |
#7
Regular Coder
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
03-16-2008, 11:04 AM
PM User |
#8
Regular Coder
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) ?
03-16-2008, 11:08 AM
PM User |
#9
New Coder
Join Date: Mar 2008
Posts: 35
Thanks: 0
Thanked 4 Times in 4 Posts
Quote:
Originally Posted by
Mihai
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
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
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.
03-16-2008, 11:11 AM
PM User |
#10
New Coder
Join Date: Mar 2008
Posts: 35
Thanks: 0
Thanked 4 Times in 4 Posts
Quote:
Originally Posted by
Mihai
how can i enable error reporting via error_reporting(E_ALL) ?
If you're seeing stuff like
Quote:
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.
03-16-2008, 08:22 PM
PM User |
#11
Super Moderator
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,604
Thanks: 2
Thanked 399 Times in 392 Posts
Please remember to read the stickies for this forum. In particular
the one about using [php][/php] tags when posting code.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 02:47 AM .
Advertisement
Log in to turn off these ads.