Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> Problem z kodem PHP, "syntax error, unexpected '='"
Kubik213
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 25.04.2009

Ostrzeżenie: (0%)
-----


Witam, co w tym kodzie jest źle ;/ bo występuje błąd:


Cytat
Parse error: syntax error, unexpected '=' in D:\xampp\htdocs\accmaker\layouts\metin\layout.php on line 124

błąd przypada na linijke: <table border=\"1\" style=\"width:80%;\" class=\"barabara\"><tr>

Cytat
<?PHP
$limit = 1;
function coloured_value($valuein)
{
$value2 = $valuein;
while(strlen($value2) > 3)
{
$value .= '.'.substr($value2, -3, 3);
$value2 = substr($value2, 0, strlen($value2)-3);
}
$value = $value2.$value;
if($valuein > 0)
return '<font color="green">+'.$value.'</font>';
elseif($valuein < 0)
return '<font color="red">-'.$value.'</font>';
else
return ''.$value.'';

}
if(empty($type))
$players = $SQL->query(' SELECT * FROM players ORDER BY `players`.`experience`-`players`.`exphist_lastexp` DESC LIMIT '.$limit)->fetchAll();
foreach($players as $player)
{

print"
<table border=\"1\" style=\"width:80%;\" class=\"barabara\"><tr>
<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><font color="red" size="1"><b>'.$player['name'].'</font></b></a><br /><font color="#CCFF99"

size="1">'.$player['level'].' '.$config_vocations[$player['vocation']].'</font></td>
<td align="right"><font color="#CCFF99" size="1">'.coloured_value($player['experience'] - $player['exphist_lastexp']).'</font></tr></td>
</td></table>
";

}
?>
Go to the top of the page
+Quote Post
vokiel
post
Post #2





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Witamy na forum:)
Używaj bbcode. Jak escapujesz " to rób to w całym ciągu, a nie tylko w pierwszej linijce.
Poprawiona wersja:
  1. <?PHP
  2. $limit = 1;
  3. function coloured_value($valuein){
  4.    $value2 = $valuein;
  5.    while(strlen($value2) > 3){
  6.        $value .= '.'.substr($value2, -3, 3);
  7.        $value2 = substr($value2, 0, strlen($value2)-3);
  8.    }
  9.    $value = $value2.$value;
  10.    if($valuein > 0) return '<font color="green">+'.$value.'</font>';
  11.    elseif($valuein < 0) return '<font color="red">-'.$value.'</font>';
  12.    else return ''.$value.'';
  13. }
  14. if(empty($type)) $players = $SQL->query(' SELECT * FROM players ORDER BY `players`.`experience`-`players`.`exphist_lastexp` DESC LIMIT '.$limit)->fetchAll();
  15. foreach($players as $player){
  16.    print '<table border="1" style="width:80%;" class="barabara"><tr>
  17.    <td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><font color="red" size="1"><b>'.$player['name'].'</font></b></a><br />
  18.    <font color="#CCFF99" size="1">'.$player['level'].' '.$config_vocations[$player['vocation']].'</font></td>
  19.    <td align="right"><font color="#CCFF99" size="1">'.coloured_value($player['experience'] - $player['exphist_lastexp']).'</font></tr></td>
  20.    </td></table>';
  21. }
  22. ?>


Ten post edytował vokiel 27.04.2009, 07:26:45
Go to the top of the page
+Quote Post
osl
post
Post #3





Grupa: Zarejestrowani
Postów: 260
Pomógł: 41
Dołączył: 6.04.2009
Skąd: Gdańsk/okolice

Ostrzeżenie: (0%)
-----


jesteś pewny że na tą linijkę? w następnych masz troche bałagan z cudzysłowami (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

EDIT: no i vokiel mnie ubiegł i wstawił poprawione już (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Ten post edytował osl 27.04.2009, 07:26:36
Go to the top of the page
+Quote Post
batman
post
Post #4





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Ludzie. Forum to nie jest wykrywacz błędów. Zainstaluj sobie dowolny edytor z kolorowaniem i sprawdzaniem składni i będziesz wiedział gdzie masz błąd.
Zamykam.
Go to the top of the page
+Quote Post

Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 18.12.2025 - 22:51