I’m trying to use echo in this code
<?php
require 'connect.php';
$query = mysqli_query($conn, "SELECT * FROM `videos`") or die(mysqli_error());
while($fetch = mysqli_fetch_array($query)){
$id= $fetch['id'];
?>
<?php echo "
<li class='col-lg-4 col-md-6 col-dm-12'>
<div class='da-card box-shadow'>
<div class='da-card-photo'>
<img src=' echo $fetch['video_name']' alt=''>
<div class='da-overlay'>
<div class='da-social'>
<h4 class='mb-10 color-white pd-20'></h4>
<ul class='clearfix'>
<li>
<a href='' data-fancybox='images'><i class='fa fa-picture-o'></i></a>
</li>
<li>
<a href='#'><i class='fa fa-link'></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
"; ?>
<?php
}
?>
I’m getting this error Parse error: syntax error, unexpected string content "", expecting "-" or identifier or variable or number in C:xampphtdocsdeskgallery.php on line 572
Why this error?
………………………………………………………..
2
Answers
You can escape the string and concatenate the variable in the place your hoping to have it like this:
You can’t use
echo
inside anecho
or should I say string statement.What you have to do is variable substitution like:
Or…
In your code:
Also you can ditch the
<?php ?>
: