RyanSF07 Posted May 2, 2009 Share Posted May 2, 2009 Hi Guys, I need help with syntax. I'm trying to put this: echo "<img src='http://www.site.com/images/". $info['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."> <br>"; Echo "<b>Website:</b> ".$info['link_website_title'] . "<br> "; Echo "<b>Description:</b> ".$info['link_website_description'] . " <br>"; Echo "<b>URL:</b> ".$info['link_website_url'] . " <hr>"; inside this: $content.= " "; So that I can echo the content variable from a template. This is working: $content.= " <img src=\"http://www.site.com/images/1241286667.gif\" . imageResize($resized[0], $resized[1], 100) .> <br> "; But when I try to call the image-name from the database with: $info['photo'] I keep getting this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Could you me help sort out the syntax? Thank you in advance for your suggestions! Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/ Share on other sites More sharing options...
premiso Posted May 2, 2009 Share Posted May 2, 2009 $content .= "<img src='http://www.site.com/images/". $info['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."> <br>"; $content .= "<b>Website:</b> ".$info['link_website_title'] . "<br> "; $content .= "<b>Description:</b> ".$info['link_website_description'] . " <br>"; $content .= "<b>URL:</b> ".$info['link_website_url'] . " <hr>"; Should take care of it. Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824340 Share on other sites More sharing options...
RyanSF07 Posted May 2, 2009 Author Share Posted May 2, 2009 Thank you Premiso. I modified my post above to include more info. Now there is no error -- but nothing is pulled from the database. Without the "content" variable -- the echos work just fine. I'm trying to do something like this: $content .= " <img src='http://www.site.com/images/". $info['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."> <br>; <b>Website:</b> ".$info['link_website_title'] . <br>; <b>Description:</b> ".$info['link_website_description'] . <br>; <b>URL:</b> ".$info['link_website_url'] . "; Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824347 Share on other sites More sharing options...
premiso Posted May 2, 2009 Share Posted May 2, 2009 You are not using the code I specified. If you want it in one statement you have to do it like this: $content .= "<img src='http://www.site.com/images/". $info['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."> <br>" . "<b>Website:</b> ".$info['link_website_title'] . "<br> " . "<b>Description:</b> ".$info['link_website_description'] . " <br>" . "<b>URL:</b> ".$info['link_website_url'] . " <hr>"; Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824349 Share on other sites More sharing options...
RyanSF07 Posted May 2, 2009 Author Share Posted May 2, 2009 Thank you -- no error. However, nothing is pulled from the database. echoing each line works (content displayed) -- but echoing the variable $content doesn't (only the works "website/description/url" are displayed.) Why is that? Thank you again for your help! Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824362 Share on other sites More sharing options...
premiso Posted May 2, 2009 Share Posted May 2, 2009 Post more code. You are setting $content to be equal to nothing somewhere in your code that is either in the loop or after the loop. Without the code I cannot tell you which or where. Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824363 Share on other sites More sharing options...
RyanSF07 Posted May 2, 2009 Author Share Posted May 2, 2009 Thank you. Here is the code: <?php include_once ("connect.php"); $data = mysql_query("SELECT * FROM links ORDER BY link_website_title ASC") or die(mysql_error()); function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = $height == 0? 0 : $target / $height; } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } while($info = mysql_fetch_array( $data )) { $resized= getimagesize("link_images/". $info['photo']); } $content .= "<img src='http://www.site/link_images/". $info['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."> <br>" . "<b>Website:</b> ".$info['link_website_title'] . "<br> " . "<b>Description:</b> ".$info['link_website_description'] . " <br>" . "<b>URL:</b> ".$info['link_website_url'] . " <hr> "; include_once ("template_links.inc"); ?> The content variable is echoed from the template with this: <p> <?php include_once ("links.php"); echo $content; ?> </p> Thanks for looking at this! Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824366 Share on other sites More sharing options...
RyanSF07 Posted May 2, 2009 Author Share Posted May 2, 2009 I see it now -- } was in the wrong spot. Thank you, Premiso! Link to comment https://forums.phpfreaks.com/topic/156566-solved-short-blurb-help-with-syntax/#findComment-824368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.