This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
When I run this code, it always shows:
Parse error: syntax error, unexpected end of file in /opt/lampp/htdocs/japan_top10_09112018/index.php on line 30
<?php
echo "<title>Top 10 Things to Do in Japan</title>";
require_once('templates/header.php');
?>
<?php
// Ask teacher: does this code is right to show errors or necessary?
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
?>
<?php
require_once('database/data.php');
?>
<div class = "container">
<h1>Top 10 things to do in Japan</h1>
<?php
foreach($data as $info) {
print_r($info["Picture"]);
echo "<hr>";
// echo '<img src="$info["Picture"]" class="img-thumbnail">';
?>
<?php
require_once('templates/footer.php');
?>
The line 30 is the last line.
You are forgetting to add a } to close your foreach
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
<?php while($row = mysqli_fetch_assoc($result): ?>
<div class="box">
<h3><?php htmlspecialchars($row['testi_name'], ENT_QUOTES); ?></h3>
<?php htmlspecialchars($row['testi_content'], ENT_QUOTES); ?>
</div>
<?php endwhile; ?>
I used : for my while loop but for some reason it display Parse error: syntax error, unexpected ':'
May i know what causes this to happen?
You are missing a closing bracket after ($result), correct representation should be as below
<?php while($row = mysqli_fetch_assoc($result)): ?>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Reference - What does this error mean in PHP?
(38 answers)
Closed 4 years ago.
I have been attempting to create a user login script in PHP, however I am met with an error telling that $_SESSION["username"] is undefined. I have session_start() inside of $_SERVER["DOCUMENT_ROOT"] . "/assets/php/main.header.php", however the variable still shows as undefined.
<?php
if (!isset($_SESSION["username"])) {
header("Location: /en/");
}
?>
<!DOCTYPE html>
<html>
<head>
<?php
include($_SERVER["DOCUMENT_ROOT"] . "/assets/php/main.header.php");
?>
<title>Profile | Project Club</title>
</head>
<body>
<h1>Profile</h1>
<p><?php echo $_SESSION["username"]?></p>
<?php
include($_SERVER["DOCUMENT_ROOT"] . "/assets/php/main.footer.php");
?>
</body>
</html>
Use session_start() at the beginning of the code.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I am trying to echo multiple images but i get the error:
"PHP Parse error: syntax error, unexpected '?>' in
/public_html/View/Pages/Home.php on line 17".
Can you give me any guidance on how to fix it? code below
<?php
for($i=0;$i<$length;$i++) {
echo ?><img class="meme-image" src="<?php $meme["$imd_id" == "$i"]->$path?>"><?php
}
?>
Try By this.
<?php
for($i=0;$i<$length;$i++) {
echo '<img class="meme-image" src='.$meme[$imd_id == $i]->$path.' ">';
}
?>
Note : You do not require to close php tag. instead of that insert this in php echo.and also you must read this For best practice.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
Here is the code below. I'm trying to put the default logo using PHP conditions in my wp theme. But it's showing an error. ( Parse error: syntax error, unexpected 'get_template_directory_uri' (T_STRING), expecting ',' or ';' in C:\wamp\www\law\wp-content\themes\digital-pro\header.php on line 64 )
if( has_custom_logo() ){
the_custom_logo();
}
else{
echo '<img src=" '.get_template_directory_uri().'/img/logo.png" alt="">';
}
Try it like this..
if( has_custom_logo() ){
the_custom_logo();
}
else{ ?>
<img src=" <?php echo get_template_directory_uri(); ?>/img/logo.png" alt="">
<?php }
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I got
Parse error: syntax error, unexpected "", expected T_STRING
in ../services/sect_inc_prev.php on line 2
<div style="text-align: right;">
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
</div>
<div class="f13"></div>
what is expected as string and where to find the place where "" is?
I need to know where the problem "empty space". I'm not php programmer at all
I deleted the 2nd line and I have no error now, but I don't know for what it was needed. The error was on friend's page that hosted on Bitrix system
You should try this :
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
Just remove backslashes... Search a little bit more next time :)
Try without slashes:
<div style="text-align: right;">
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>
</div>
<div class="f13"></div>