Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.