Jump to content

Recommended Posts

I've got a little statement that uses the DO cmd to repeat a query on my db, but I have to put it in the middle of my echo.  I keep getting an error on this line, yet I can't figure out what's not correct.  Any ideas?

 

My code that it fails on:

 

echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ; 

 

My complete code:

 

<?php
  if(isset($_GET['category'])){
echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ; 
do {
echo '<div class="catdetail_header"><h1 class="style1">'.ucwords($row_rs_multi_dl['title']).'</h1></div>
<div class="catdetail_desc"><p>'.$row_rs_multi_dl['description'].'</p></div>
<div class="catdetail_footer"><a href="downloads/'.$row_rs_multi_dl['filetype'].'/'.$row_rs_multi_dl['filename'].'">Download Now</a></div>';
    } 
    while($row_rs_multi_dl = mysql_fetch_assoc($rs_multi_dl));
}
else{
echo "<div class="catdetail_header"><h1 class="style1">Please Choose A Category</h1></div>";
do {
echo '<div class="catdetail_header"><h1 class="style1"><a href="1">'.ucwords($row_rs_showcats['category']).'</a></h1>
while($row_rs_showcats = mysql_fetch_assoc($rs_showcats))';
}
?>

 

Thank You!

Link to comment
https://forums.phpfreaks.com/topic/149134-solved-php-do-in-echo-statement/
Share on other sites

You are using single quotes and double quotes incorrectly.  Use double quotes for the whole string, and when you want to break in and out, but for values of attributes use single quotes:

 

echo "".ucwords($row_rs_multi_dl['category']).""; 

Look at this line with a syntax highlighter:

echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ;

echo '<div class="catdetail_header"><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>' ;

 

See the difference?

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.