The error appears as follows:
It seems to be a grammatical error, but is it written incorrectly?
Error:
Parse error: syntax error, unexpected '$_SESSION'(T_VARIABLE), expecting', 'or'; 'in/var/www/html/php_kadai/php_kadai09/postdone.php on line48
Where applicable:
<?phpecho"<img src="$_SESSION["img_data"]"><br><br>br>";?>
<?php
require_once('functions.php');
session_start();
var_dump($_SESSION["img_data"]);
// $name = $_POST ['name'];
// $image_name = $_POST ['image_name'];
// $img_data="images/".$_FILES["img_data"]["name"];
// $dbh = connectDb();
// $sql="insert into posts(create_at, name, image_name, img_data) values
// (now(), :name, :image_name, :img_data)";
// $stmt = $dbh->prepare($sql);
// $stmt->bindParam(":name", $name);
// $stmt->bindParam(":image_name", $image_name);
// $stmt->bindParam(":img_data", $img_data);
// $stmt->execute();
?>
<!DOCTYPE html>
<html>
<head>
<metacharset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Post Completion Page</title>
<link rel="stylesheet" href="reset.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Image Posting Bulletin Board</h1>
<hr>
<divid="wrapper">
<p class="title"> Post with the following contents</p>
<p>Posters: <?phpechoh($_SESSION["name"]);?>/p>
<p class="imagestate">Image Title:<?phpechoh($_SESSION["image_name"]);?></p>
<p>image files:<br>
<?phpecho$_FILES["img_data"]["name"]."<br>";?>
<?phpecho"<img src="$_SESSION["img_data"]">br>br>br>";?>
</p>
<p class="return"><a href="posting.php">Return to image posting page>>/a>>
<p class="link"><a href="index.php">View image listing hage here>>/a>>
</div>
</body>
</html>
<?phpecho"<img src="$_SESSION["img_data"]">br>br>br>";?>
portion
You must escape with \
to write "
in the string, i.e., "
and "
.
So, I'll write it like this.
echo"<img src=\"$_SESSION[img_data]\">br>br>br>";
The "img_data"
portion does not write "
if it is embedded in a string.
"<img src="$_SESSION["img_data"]">br>br>br>br>"
Because the string enclosed by two "
("<img src="
and "<br>"<br>"
) and one variable ($_SESSION["img_data"]
) must be combined.
"<img src=".$_SESSION["img_data"].">br>br>br>br>"
© 2024 OneMinuteCode. All rights reserved.