当我运行此查询时,图像正在从PHP正确显示。
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("dawat");
$submit=$_GET['str'] ;
$sql = mysql_query("SELECT * FROM searchengine WHERE pagecontent LIKE '%$_GET%' ");
while($row=mysql_fetch_array($sql)) {
echo "<img src=image.php?pagecontent=".$row['pagecontent']." />";
}
?>
image.php的代码:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysql_connect("localhost","root","");
if(!$conn)
{
echo mysql_error();
}
$db = mysql_select_db("dawat",$conn);
if(!$db)
{
echo mysql_error();
}
$pagecontent = $_GET['pagecontent'];
$q = "SELECT pageurl FROM searchengine where pagecontent='$pagecontent'";
$sql = mysql_query("$q",$conn);
if($sql)
{
$row = mysql_fetch_array($sql);
echo $row['pageurl'];
}
else
{
echo mysql_error();
}
?>
当我在上面运行相同的代码时,只需对搜索脚本进行一些更改:
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("dawat");
$submit=$_GET['str'] ;
$sql = mysql_query("SELECT pageurl, BIT_COUNT(pagecontent^'$submit')
FROM searchengine WHERE pagecontent < 20 ORDER BY pagecontent ASC;
") or die(mysql_error());
while($row=mysql_fetch_array($sql)) {
echo "<img src=image.php?pagecontent=".$row['pagecontent']." />";
}
?>
它显示错误,未定义索引:pagecontent,也没有显示图像。请提前帮助和谢谢。
答案 0 :(得分:3)
在您的查询中
$sql = mysql_query("SELECT pageurl, BIT_COUNT(pagecontent^'$submit')
FROM searchengine WHERE pagecontent < 20 ORDER BY pagecontent ASC;
") or die(mysql_error());
您没有获取列pagecontent
并尝试在
echo "<img src=image.php?pagecontent=".$row['pagecontent']." />";
^
将您的查询更改为
$sql = mysql_query("SELECT pageurl,pagecontent, BIT_COUNT(pagecontent^'$submit')
FROM searchengine WHERE pagecontent < 20 ORDER BY pagecontent ASC;
") or die(mysql_error());
答案 1 :(得分:1)
尝试并从$ sql获取打印值..您将了解如何返回它..
$sql = mysql_query("SELECT pageurl,pagecontent, BIT_COUNT(pagecontent^'$submit')
FROM searchengine WHERE pagecontent < 20 ORDER BY pagecontent ASC;
") or die(mysql_error());