如何再次在PHP和PHP中用HTML编写HTML?

How to write HTML in PHP and PHP in HTML again?

The following error message appears:

Parse error: syntax error

<?php 
    echo"<div class='vod'>    

         "   /////// i need right php her
          $con = mysqli_connect ("localhost","root","","demo");

        $id = @addcslashes ($_REQUEST['id']);

        $image = mysqli_query ($con,"SELECT * FROM img WHERE id= '$id '")or  die(mysqli_error($con));
        $image = mysqli_fetch_assoc ($image);
        $image = $image['img'];


        header ("content-type: image/jpeg");
        echo $image ; "

    </div>";
?>

Its a simple typo I am afraid. You just missed a ; after the first echo and missed the echo command on the last line that outputs the last div

While developing a script it is a good idea to make sure you have error reporting turned on.

<?php 
    // turn on error reporting while developing a script
    ini_set('display_errors', 1); 
    ini_set('log_errors',1); 
    error_reporting(E_ALL); 
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

    echo"<div class='vod'>";
    // missing semi colon  ^

    $con = mysqli_connect ("localhost","root","","demo");
    $id = @addcslashes ($_REQUEST['id']);

    $image = mysqli_query($con,"SELECT * FROM img WHERE id= '$id'")
            or die(mysqli_error($con)); 
    $image = mysqli_fetch_assoc ($image); 
    $image = $image['img'];

    header ("content-type: image/jpeg"); 
    echo $image;

    echo "</div>";
//  ^^^^ the echo here was also missing
?>

Note: You should also use prepared parameterised queries to protect your scripts from SQL Injection Attacks

actually this is a not good idea to mix html with php or sql. You should try to sepaarete templates and dev logic.

For example you can create folder 'templates' in your project and than in html you can read this template. The same for sql.

The good practice is too use template engine, for example twig

Finally you can look on frameworks side. I would like to recomand you Symfony or Laravel.

That might work.

<?php

    // header has to appear before any html-tag; sure, that this is correct?
      header("content-type: image/jpeg");

    echo "<div class='vod'>";

      // connect to db and initialize parameters
        $con = mysqli_connect("localhost","root","","demo");
        $id = @addcslashes($_REQUEST['id']);

      // get image src
        $result = mysqli_query($con,"SELECT * FROM img WHERE id='.$id.'") or die(mysqli_error($con));
        $result = mysqli_fetch_assoc($result);
        $image = $result['img'];  // are you sure, that "img" is what you need? I think you need the path where the image is saved at

    echo "<img src='".$image."' alt='Text that shows up if Image cannot be displayed'></div>";
?>