30. september 2004 - 17:14
Der er
2 kommentarer og 1 løsning
' og " fejl i script
<?php if($_COOKIE['loged'] == 'yes') { echo '<td class="menu_item2" style="background:'#585858';" onclick="document.location.href='user_logout.php';" onmouseover="this.style.backgroundColor='#666666'" onmouseout="this.style.backgroundColor='#585858'"><img src="site_files/gfx/pil.gif" width="9" height="9" align="absmiddle"> <span class="style2">U</span>ser <span class="style2">L<span class="style3">ogout</span></span></td>'; }else{ echo '<td class="menu_item2" style="background:'#585858';" onclick="document.location.href='user_login.php';" onmouseover="this.style.backgroundColor='#666666'" onmouseout="this.style.backgroundColor='#585858'"><img src="site_files/gfx/pil.gif" width="9" height="9" align="absmiddle"> <span class="style2">U</span>ser <span class="style2">L<span class="style3">ogin</span></span></td>'; } ?> Får denne fejl: Parse error: parse error, unexpected '}', expecting ',' or ';' in /customers/explosif.dk/explosif.dk/httpd.www/menu.php on line 36 Nogen der kan hjælpe mig med en løsning? For hvis jeg ændrer alle ' til " virker det desværre ikke! Altså så er det ikke muligt at ændre: onmouseout="this.style.backgroundColor='#585858'"> til: onmouseout="this.style.backgroundColor="#585858"">
Annonceindlæg fra itavis
30. september 2004 - 17:18
#1
<?php if($_COOKIE['loged'] == 'yes') { echo <<<STOP <td class="menu_item2" style="background:'#585858';" onclick="document.location.href='user_logout.php';" onmouseover="this.style.backgroundColor='#666666'" onmouseout="this.style.backgroundColor='#585858'"><img src="site_files/gfx/pil.gif" width="9" height="9" align="absmiddle"> <span class="style2">U</span>ser <span class="style2">L<span class="style3">ogout</span></span></td> STOP; }else{ echo <<<STOP <td class="menu_item2" style="background:'#585858';" onclick="document.location.href='user_login.php';" onmouseover="this.style.backgroundColor='#666666'" onmouseout="this.style.backgroundColor='#585858'"><img src="site_files/gfx/pil.gif" width="9" height="9" align="absmiddle"> <span class="style2">U</span>ser <span class="style2">L<span class="style3">ogin</span></span></td> STOP; } ?> Men hvorfor så meget? Du kan bare gøre sådan i din HTML: <td class="menu_item2" style="background:'#585858';" onclick="document.location.href='user_log<?= ( $_COOKIE['loged'] == 'yes' ? 'out' : 'in' ) ?>'.php';" onmouseover="this.style.backgroundColor='#666666'" onmouseout="this.style.backgroundColor='#585858'"><img src="site_files/gfx/pil.gif" width="9" height="9" align="absmiddle"> <span class="style2">U</span>ser <span class="style2">L<span class="style3">og<?= ( $_COOKIE['loged'] == 'yes' ? 'out' : 'in' ) ?></span></span></td>
30. september 2004 - 17:29
#2
Hmm, den havde jeg ikke lige tænkt på! Fantastisk, mange tak for hjælpen! :)