Syntax error unexpected '<' on line 11 [closed] - php

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.

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>';
}
?>

How can i fix this parse error [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
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.

Use echo in a css class [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
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
I am using php echo throughout different pages on a project, to update a percentage value that is changing daily. This value can be negative or positive.
Here is my code:
<i class="icon-thumbs-up"><strong> <?php $file = file('include.txt');echo $file[n]; ?></strong></i>
I am using FontAwesome icons with a Bootstrap template. Everything is working fine like this.
Now, if the percentage is negative, I would like to use class="icon-thumbs-down" instead of class="icon-thumbs-up".
I have tried to achieve this using
<i class="<?php $file = file('include.txt');echo $file[n]; ?>"><strong> <?php $file = file('include.txt');echo $file[13]; ?></strong></i>
in order to change it on all pages.
However, this is not working. Thanks for any hints!
To clarify:
<i class="icon-thumbs-up"><strong> <?php $file = file('include.txt');echo $file[0]; ?></strong></i>
Content of include.text: 0.58% on line 1 -> All working fine. I got the thumbs up displayed and next to it the value 0.58%.
Now I tried to change to:
<i class="<?php $file = file('include.txt');echo $file[1]; ?>"><strong> <?php $file = file('include.txt');echo $file[0]; ?></strong></i>
Content of include.text: 0.58% on line 1 and icon-thumbs-up on line 2. (Which I would like to change in the include.txt on a daily basis to icon-thumbs-up or icon-thumbs-down, depending on the value of line 1.)
If value from file('include.txt') is integer then you can use ternary operator to echo correct css class, eg. like this:
<li class="<?php echo (int) $file[0] < 0 ? 'icon-thumbs-down' : 'icon-thumbs-up'; ?>"></li>
This is a bit hard to reply to as your code isnt that clear. I can however hand you the following suggestion via an example:
$someInt = 10;
echo $someInt < 0 ? 'icon-negative' : 'icon-positive'; // will echo positive
$someInt = -3;
echo $someInt < 0 ? 'icon-negative' : 'icon-positive'; // will echo negative
This is a short if/else (ternary). To demonstrate how it works, this would be the same in a full syntax:
$someInt = -3;
if($someInt < 0){
echo 'icon-negative';
}
else{
echo 'icon-positive';
}
I would do the following:
<?php
// your logic here, move in another file if this gets bigger:
function percentage($nb) {
$file = file('include.txt');
return $file[$nb];
}
?>
<i class="<?php echo percentage(5) > 0 ? 'positive' : 'negative' ?>">
<strong>Text</strong>
</i>

PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' [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
Could someone correct this code:
echo "<div style="float:right;"><a href='index.php?img1=$img1_id&img2=$img2_id'><img src='$img1_url' /></a></br>Asd: $img1_asd</div>";
echo "<div style="float:right;"><a href='index.php?img1=$img2_id&img2=$img1_id'><img src='$img2_url' /></a></br>Asd: $img1_asd</div>";
I'm getting the error which is specified in the title
Learn Escape Sequence .
echo "<div style=\"float:right;\"><a href='index.php?img1=$img1_id&img2=$img2_id'><img src='$img1_url' /></a></br>Asd: $img1_asd</div>";
echo "<div style=\"float:right;\"><a href='index.php?img1=$img2_id&img2=$img1_id'><img src='$img2_url' /></a></br>Asd: $img1_asd</div>"
echo '<div style="float:right;"><a href="index.php?img1='.$img1_id.'&img2='.$img2_id.'><img src='.$img1_url.' /></a></br>Asd: '.$img1_asd.'</div>';
echo '<div style="float:right;"><a href="index.php?img1='.$img2_id.'&img2='.$img1_id.'><img src='.$img2_url.' /></a></br>Asd: '.$img1_asd.'</div>';
Come on you can do better...
echo "<div style='float:right;'>",
"<a href='index.php?img1=", $img1_id, "&img2=", $img2_id, "'>",
"<img src='", $img1_url, "' />",
"</a><br />",
"Asd: ", $img1_asd",
"</div>";
This even has & correctly escaped to &
Remember, closing void tags is only neccessary for XHTML: <br />
not in HTML4 and HTML5.
This is even wrong³: </br>

Switch Statment Give Always The default [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 8 years ago.
Improve this question
I have a problem in my script in wampserver. It runs well. But in my hosting it doesn't display
the page which is named classed.php?cat=[category_Name_Example]
<?php header("Content-type: text/html; charset=utf-8");
?>
<?php include_once("analyticstracking.php") ?>
<?php
include 'includis/html_codes.php';
include 'includis/config.php';
$catID= mysql_real_escape_string($_GET['cat']);
switch ($catID)
{
case 'javascript' :
$catName = "javascript";
$PageTitle = "Javascript ";
$img = "img/javascript.png";
break;
case 'htmlandcss' :
$catName = "htmlandcss";
$PageTitle = "html ";
$img = "img/html2.png";
break;
default:header('location: /404');
}
if (!isset($catID)){
header ('Location 404.php');
}
if (empty($catID)){header ('Location 404.php');}
include 'includis/db.php';
?>
please help thanx :)
Most probable reason is that you do not have an open database connection while calling to this function. In this case mysql_real_escape_string just returns false.

Categories