How can i fix this parse error [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 8 years ago.
Improve this question
Parse error: syntax error, unexpected T_DOUBLE_ARROW
i am a beginner at best when it comes to php
below is the code
<?php endwhile; wp_reset_query(); ?>
<?php $mytrails = new WP_Querry)
'post_type' => '$mytrails'
)); ?>
<?php while($mytrails->have_posts()) : $mytrails->the_post();?>
<div class="large-6 columns">
<div class="panel">
<div class="thumbtitle group">
<div class="thumbnail">
<?php the_post_thumbnail('thumbnail');?>

Replace:
<?php $mytrails = new WP_Querry)
'post_type' => '$mytrails'
)); ?>
With:
<?php $mytrails = new WP_Query( array(
'post_type' => $mytrails
) ); ?>
In your version there's a typo in WP_Query, a missing array, a closing bracket where there shouldn't be one, and a variable inside single quotes.

Related

Syntax error PHP code [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 7 years ago.
Improve this question
I have this code:
?php
if ( is_page('1708')) {
<div id="portofoliu"></div>
}
?>
And this my error:
Parse error: syntax error, unexpected '<' in /home/dacproie/public_html/eventos/wp-content/themes/eventos/header.php on line 141
What is wrong in this code?
Can you help me to solve this problem please?
Thanks in advance!
Missing echo:
<?php
if ( is_page('1708')) {
echo '<div id="portofoliu"></div>';
}
?>
You can't mix HTML and PHP this way.
Another option is (for longer HTML code):
<?php
if ( is_page('1708')) {
?>
<div id="portofoliu"></div>
<?php
}
?>
OR
<?php
if ( is_page('1708')) :
?>
<div id="portofoliu"></div>
<?php
endif;
?>
And, of course, PHP begins with <?php but it seems to be just copy&paste error.
Might seem obvious but... You need to escape your html to be a string. Otherwise PHP trys to execute it.
<?php
if ( is_page('1708')) {
echo '<div id="portofoliu"></div>';
}
?>
You forgot to close and open PHP tags:
<?php
if ( is_page('1708')) {
?>
<div id="portofoliu"></div>
<?php
}
?>
try
<?php
if ( is_page('1708')) {
echo '<div id="portofoliu"></div>';
}
?>

php echo div class not working [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 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.

If else - how to switch between two php files depending on the url [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So, I would like to switch between 2 php files depending on the url. So far my code looks like this...
<?php $url = $_SERVER["REQUEST_URI"];
if (strpos($url, "/ru/")) {
<?php wp_nav_menu(array('theme_location' => 'Tours-en')); ?>
}else {
<?php wp_nav_menu(array('theme_location' => 'Tours-ru')); ?>
}
?>
I don't know what should be before <?php wp_nav_menu(array('theme_location' => 'Tours-en')); ?> like use <? php wp_nav_menu etc.. I hope you see what is my problem. I don't know the name of the "command" which should be before <?php.
To clarify, the two php files between which I would like to switch contain menus.
Any help would be appreciated.
What about this:
<?php
$url = $_SERVER["REQUEST_URI"];
wp_nav_menu(array(
'theme_location' => (strpos($url, "/ru/"))?'Tours-en':'Tours-ru'
));
?>

Syntax error unexpected '<' on line 11 [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
Syntax error unexpected '<'
Code is:
$new_notifs = mysql_query("SELECT ID FROM Notifications WHERE ToID='$MyID' AND IsNew='1'") or die(mysql_error());
$new_notifs = mysql_num_rows($new_notifs);
if($new_notifs>0) {
$new_notif_block = " disBlock";
} else {
$new_notif_block = NULL;
$new_notifs = NULL;
}
<div id='header'>
<div id='headerContainer'>
<h1 id='pageLogo'>
</h1>
<div id='fbRequestsJewel' class='fbJewel<?php echo $new_friend_active; ?>'>
<span class='fbJewelNotif<?php echo $new_friend_block; ?>' id='requestJewelNotif'><?php echo $new_friends;?></span>
<div id='fbJewelRequestsPopup' class="jewelPopup">
<div class='fbJRPcover disBlock'></div>
<div class='fbJewelTitle'>
Friend Requests
<a class='fright lightBlue noBold' href='find.php'>Find Friends</a>
</div>
Close your PHP tag:
$new_notifs = mysql_query("SELECT ID FROM Notifications WHERE ToID='$MyID' AND IsNew='1'") or die(mysql_error());
$new_notifs = mysql_num_rows($new_notifs);
if($new_notifs>0) {
$new_notif_block = " disBlock";
} else {
$new_notif_block = NULL;
$new_notifs = NULL;
}
?>
<div id='header'>
Note the ?> before <div id='header'>.
At the moment, you're not closing your PHP tags, which means that PHP is trying (and failing) to parse <div id='header'>, hence the Syntax error unexpected '<' error.

How to find the category Id in the wordpress? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am new to wordpress , I need to know how to find the category id instead of category name ?
in the wordpress .
Any one Much appreciated
Reg,
vicky
<?php
$category_id = get_cat_ID('Category Name');
$q = 'cat=' . $category_id;
query_posts($q);
if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;
?>
Taken from the Wordpress Codex: http://codex.wordpress.org/Function_Reference/get_cat_ID
Did you try?
global $wp_query;
$cat_ID = get_query_var('cat');

Categories