我尝试了很多次尝试从数据库中获取blob图像并在代码中进行了很多更改我无法解决此错误。我在代码中加粗了这一行。如果我删除该标签代码工作,但使用该标签我得到一个错误。为什么会出现此错误以及解决方案是什么。 //错误 解析错误:语法错误,意外“数据”(T_STRING),期待“,”或“;”在第18行的C:\ xampp \ htdocs \ project \ DBMS \ index.php
<html>
<?php
require "connect.php";
$sql="select * from newbook";
$row = $conn->query($sql);
$n=0;
echo"<form method='post'><table border='0' align='center'><tr>";
while($arr = $row->fetch_assoc())
{
$i=$arr['BookId'];
if($n%4==0)
{
echo "<tr>";
}
echo "
**<td height='280' width='240' align='center'><img src="data:image/jpeg;base64,'.base64_encode( $arr['BookImage'] ).'"height='200' width='200'><br/>**
<b>BOOKNAME:</b>".$arr['BOOKNAME'].
"<br><b>Author:</b>".$arr['Author'].
"<br><b>Publication:</b> ".$arr['PublicatonHouse'].
"<br><b>Discount:</b>".$arr['Discount']."%".
"<br><br><img src='images/MetalPlakDa5new.gif' width='70' height='20'/></a>
<img src='images/view7.jpg' width='70' height='20'/></a>
</td>";
$n++;
}
echo "</tr></table>
</form>";
?>
</body>
</html>
答案 0 :(得分:2)
好吧,你的引号都是错误的顺序,它试图将文本解析为PHP。
<html>
<?php
require "connect.php";
$sql="select * from newbook";
$row = $conn->query($sql);
$n=0;
echo"<form method='post'><table border='0' align='center'><tr>";
while($arr = $row->fetch_assoc())
{
$i=$arr['BookId'];
if($n%4==0)
{
echo "<tr>";
}
echo "
**<td height='280' width='240' align='center'><img src='data:image/jpeg;base64,".base64_encode( $arr['BookImage'] )."'height='200' width='200'><br/>**
<b>BOOKNAME:</b>".$arr['BOOKNAME']."
<br><b>Author:</b>".$arr['Author']."
<br><b>Publication:</b> ".$arr['PublicatonHouse']."
<br><b>Discount:</b>".$arr['Discount']."%
<br><br><img src='images/MetalPlakDa5new.gif' width='70' height='20'/></a>
<img src='images/view7.jpg' width='70' height='20'/></a>
</td>";
$n++;
}
echo "</tr></table>
</form>";
?>
</body>
</html>
答案 1 :(得分:1)
echo "
**<td height='280' width='240' align='center'><img src='data:image/jpeg;base64,".base64_encode( $arr['BookImage'] )."'height='200' width='200'><br/>**
您在数据前使用双括号,使用单引号代替并使用单引号结束。试试以上。您的问题与BLOB无关。