php echo div class not working [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am trying to echo a div class <div class="Box"> but not working. Can anyone help? Thanks.
echo '<div class="Box">
echo Anchor(T('Edit My Account'), '/profile/edit', FALSE, array('class' => 'Popup EditAccountLink'));
echo "<br />";
echo Anchor(T('Change My Password'), '/profile/password', FALSE, array('class' => 'Popup PasswordLink'));
echo "<br />";
$Inbox = 'Inbox';
$CountUnreadConversations = $Session->User->CountUnreadConversations;
if (is_numeric($CountUnreadConversations) && $CountUnreadConversations > 0)
$Inbox .= ''.$CountUnreadConversations.'';
echo Anchor(T('Inbox'), '/messages/all', 'Inbox');
</div>'

Your first and last lines are wrong, missing proper quotation marks and also an echo on the last line. It should be:
echo '<div class="Box">';
.... rest of code here...
echo '</div>';

You haven't terminated the string with ';.
echo '<div class="Box">';

Enable the error_reporting to E_ALL. Read on documentation. After this, you know what is happen.

This is a parse error. Enable error_reporting to E_ALL.

Related

Echo out values in foreach loop [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have this code:
if(!empty($item['criteria'])){
foreach ($item['criteria'] as $item2){
echo "$item2[description]<br/>".PHP_EOL;
}
}
}
Now i need to modify this code to swing open the $item2[description]. I tried it like that:
if(!empty($item['criteria'])){
foreach ($item['criteria'] as $item2){
echo ''Click
<div id="', $item2['id'], '" style="display: none">', $item2['description'], '</div>';
}
}
}
I think there is a mistake in some signs.
if(!empty($item['criteria'])){
foreach ($item['criteria'] as $item2){
echo 'Click';
echo '<div id="'. $item2['id'].'" style="display: none">'. $item2['description'].'</div>';
}
}
}
you have some syntactical mistakes check this once
Use the . to concat strings
if(!empty($item['criteria'])){
foreach ($item['criteria'] as $item2){
echo 'Click'.
'<div id="'.$item2['id'].'" style="display: none">'.$item2['description'].'</div>';
}
}

Jquery syntax error Unexpected token < [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I get the following error and don't know where my mistake is:
Unexpected token <
Code (echo because of PHP used):
echo '<script type="text/javascript">
$(document).ready(function(){$("#sellerDrafts > tbody:last").append(';
foreach($this->view->sellercentral as $key2 => $value2)
{
echo '<tr><td><a href='. $value2->itemToken .'>Edit</a></td></tr>';}
echo '});</script>';
The problem is that you do not have quotes "" surrounding your append (and href), and it is not being closed with );.
echo '<script type="text/javascript">
$(document).ready(function(){$("#sellerDrafts > tbody:last").append("';
foreach($this->view->sellercentral as $key2 => $value2)
{
echo '<tr><td>Edit</td></tr>';
}
echo '");});</script>';
On a side note, this is really not the best way to do this. A better way to do this would be to build it in PHP first then hand it off to your javascript. Like so:
<?php
$table = "";
foreach($this->view->sellercentral as $key2 => $value2)
{
$table = '<tr><td>Edit</td></tr>';
}
?>
<script type="text/javascript">
$(document).ready(function(){
$("#sellerDrafts > tbody:last").append("<?php echo $table; ?>");
});
</script>

PHP echo filename into img src [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a image filename stored and i want to echo it into some code where it will be a hyperlink to another page but it also gets the filename from the stored data.
echo " <a href=\"ProductDescription.php?productid=" . $row['productid'] . \" >
<img src=\"/admin/images/ . $row['image'] . \" alt=\"product image\" width=\"40\"
height=\"65\"></a> ";
The error I'm getting is
Parse error: syntax error, unexpected '"', expecting T_STRING
I just can't seem to figure out my syntax problem to get it to work.
just check your double-quotes
echo " ";
You forgot to add the " after productid. And also forgot to add it around image.
Do it via:
echo "<img src=\"/admin/images/$row['image']\" alt=\"product image\" width=\"40\" height=\"65\">";
Or
echo " ";
This should fix the error:
echo " <a href=\"ProductDescription.php?productid=" . $row['productid'] . " \" ><img src=\"/admin/images/" . $row['image'] ."\" alt=\"product image\" width=\"40\"
height=\"65\"></a> ";

echo inside an echo - does it work? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
It's been a long time since I have done php so sorry for the silly question.
This is my current code, I'm trying to save the URL as a variable so that I can insert it into the echo, but it doesn't seem to work as nothing appears:
<?php ob_start();
echo get_post_meta($post->ID, 'oldurl', true);
$old_url = ob_get_contents();
ob_end_clean();
?>
<?php echo do_shortcode('[fbcomments][fbcomments url="$old_url" width="375" count="off" num="3" countmsg="wonderful comments!"]'); ?>
I have echoed $old_url and can see that it has the correct value, but how do I insert the value into the echo do_shortcode with url="$old_url"?
This doesn't work either:
<?php echo do_shortcode('[fbcomments][fbcomments url="echo $old_url;" width="375" count="off" num="3" countmsg="wonderful comments!"]'); ?>
You'll need to switch your quotes around. Single quotes print everything out as-is. Double-quotes will process the variables. Also, echo is not needed within an echo.
<?php echo do_shortcode("[fbcomments][fbcomments url='$old_url' width='375' count='off' num='3' countmsg='wonderful comments!']"); ?>
Another way to do it without switching your quotes is to break out of the statement:
<?php echo do_shortcode('[fbcomments][fbcomments url="'.$old_url.'" width="375" count="off" num="3" countmsg="wonderful comments!"]'); ?>
Variables are not replaced in single quotes ...
<?php echo do_shortcode('[fbcomments][fbcomments url="' . $old_url . '" width="375" count="off" num="3" countmsg="wonderful comments!"]'); ?>
Singles quotes doesn't allow variables parsing.
For example :
$var = 'Hello';
echo 'The content of my var is : $var';
// Will output : "The content of my var is : $var"
echo "The content of my var is : $var";
// Will output : "The content of my var is : Hello"
So you have to use double quotes or use the concatenate operator : .

add inline style to div tag in php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The following code has no problem, I just need to add an inline style as
<div id="nav-menu" style="width:65px;"> to it. I need your help to include that style.
<?php
$pages = array('health.php' => 'Health',
'weightloss.php' => 'Weight Loss',
'fitness.php' => 'Fitness',
'sex.php' => 'Sex',
'mindbody.php' => 'Mind-Body',
'food.php' => 'Food',
'beauty.php' => 'Beauty',
'more.php' => 'More');
echo "<div id=\"nav-menu\">\n";
// let's create a unordered list to display the items
echo "<ul>";
// here's where all the items get printed
foreach ($pages as $Listing) {
echo "<li>$Listing</li>\n";
}
// closing the unordered list
echo "</ul>";
echo "</div>\n";
?>
Do you mean this?
echo "<div id=\"nav-menu\" style=\"width:65px;\">\n";
OR
echo "<div id='nav-menu' style='width:65px;'>\n";
OR
echo '<div id="nav-menu" style="width:65px;">' . "\n";
echo "<div id=\"nav-menu\" style=\"width:65px;\">\n";
echo '<div id="nav-menu" style="width:65px;">';
By default you cannot set a width for a block element like <div>; it takes up the full width of its container.
try: echo "<div id=\"nav-menu\" style=\"width:65px;display:inline-block;\">\n";

Categories