Jkl*_*lyn 1 php mysql database facebook
我从mysql数据库中提取了要在facebook共享上看到的og图像.下面的代码已经有效,但唯一的问题是它显示错误:" /> 在我的主页顶部.
如何" />从我的主页上删除此标志?我在这段代码上犯了什么错误吗?
对我的问题的任何指导表示赞赏.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$fetch_sql = "SELECT fld_news_pictures, fld_news_name, fld_news_details FROM tbl_news ";
$fetch_result= mysql_query($fetch_sql) or die(mysql_error());
while($fetch_row=mysql_fetch_array($fetch_result))
{
$fld_news_name = $fetch_row['fld_news_name'];
$fld_news_pictures = $fetch_row['fld_news_pictures'];
$fld_news_details = $fetch_row['fld_news_details'];
?>
<meta property="og:title" content="<?php echo $fld_news_name; }?>" />
<meta property="og:image" content="http://mysite/images/<?php echo $fld_news_pictures; ?>" />
<meta property="og:description" content="<?php echo $fld_news_details } ?>" />
Run Code Online (Sandbox Code Playgroud)
编辑:你的og:title标签内有一个额外的支架}?>应该被移除.这应该使用错误报告抛出一个解析错误.
.php扩展名.顺便说一下,mysql_函数已被弃用,将在PHP 7.0中删除
习惯使用mysqli_或PDO准备好的语句.
此外,您不知道要使用哪个MySQL API进行连接.根据您发布的内容,它应该是mysql_或不是mysqli_PDO.那些不同的API不会混用.
mysqli_或PDO,然后将整个代码转换为更新的API.重写:(放在<head></head>你的文件里面)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$fetch_sql = "SELECT fld_news_pictures, fld_news_name, fld_news_details FROM tbl_news ";
$fetch_result= mysql_query($fetch_sql) or die(mysql_error());
while($fetch_row=mysql_fetch_array($fetch_result))
{
$fld_news_name = $fetch_row['fld_news_name'];
$fld_news_pictures = $fetch_row['fld_news_pictures'];
$fld_news_details = $fetch_row['fld_news_details'];
?>
<meta property="og:title" content="<?php echo $fld_news_name; ?>" />
<meta property="og:image" content="http://mysite/images/<?php echo $fld_news_pictures; ?>" />
<meta property="og:description" content="<?php echo $fld_news_details; ?>" /> <?php } ?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
137 次 |
| 最近记录: |