Jump to content

[SOLVED] short blurb -- help with syntax


RyanSF07

Recommended Posts

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

$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.

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'] . 

";

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>";

 

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!

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!

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.