Jump to content

[SOLVED] how i do this?


ohdang888

Recommended Posts

thanks, but one problem...

its giving this error:

 

 

Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\game.php on line 61

 

 

 

heres my full code

<?php

$game_pic = stripslashes($row['game_picture_url']);

  if (strlen($game_pic) > 0) {
    <IMG SRC="gamepic/<?php echo stripslashes($row['game_picture_url'])?>" WIDTH="150" HEIGHT="110" BORDER="0" ALT= "free online (THIS IS LINE 61)
games, free flash games">
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/84014-solved-how-i-do-this/#findComment-427737
Share on other sites

your mixing html and php without echoing it...

 

rewrite your code to this

<?php

$game_pic = stripslashes($row['game_picture_url']);

  if (strlen($game_pic) > 0) {
    echo "<IMG SRC="gamepic/";
    echo stripslashes($row['game_picture_url']). " ' WIDTH='150' HEIGHT='110' BORDER='0' ALT= 'free online (THIS IS LINE 61)
games, free flash games">";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/84014-solved-how-i-do-this/#findComment-427783
Share on other sites

<?php

$game_pic = stripslashes($row['game_picture_url']);

  if (strlen($game_pic) > 0) {
    ?>

<IMG SRC="gamepic/<?=stripslashes($row['game_picture_url']) ?>"  WIDTH="150" HEIGHT="110" BORDER="0" ALT= "free online games, free flash games">
<?php
  }

?>

 

Try that... the single and double quotes were being mixed and not escaped properly.

 

Link to comment
https://forums.phpfreaks.com/topic/84014-solved-how-i-do-this/#findComment-427820
Share on other sites

Notice how I dropped out of PHP and into HTML and back when needed. This can sometimes make the code a bit sloppy, but it allows you to avoid a lot of single and double quotes and escaping them properly and such.

 

I always try to use ' ' when possible.

 

for example..

 

<?php
$var1='<a href="#" class="someclass">This is my string when I need to </a>escape for a '.$variable .' I do so like that see '.$anothervar;
?>

Notice how I did not have to escape the hell out of the HTML. It helps in the long run. :)

 

Hope I helped some.

 

Nate

Link to comment
https://forums.phpfreaks.com/topic/84014-solved-how-i-do-this/#findComment-429075
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.