Rumah  >  Artikel  >  pembangunan bahagian belakang  >  帮忙看看一下数据库连接的异常!

帮忙看看一下数据库连接的异常!

WBOY
WBOYasal
2016-06-13 10:05:00992semak imbas

帮忙看看一下数据库连接的错误!!!
[email protected]_connect("localhost","root","Admin","test");
$sql="select pic from $table where id=$id";
$result=mysql_db_query("photo",$sql);
$image=mysql_result($result,0,"pic");
echo $image;
?>

if($offset == "")
{$offset = 0;}
$Connid = @mysql_connect("localhost","root","Admin","test");
$sql = "select id,name from photo order by id desc limit $offset,6";
$result = mysql_db_query("photo",$sql);
$num = mysql_num_rows($result);
if($num != 0)
{
$i = 0;
  while($r = mysql_fetch_array($result))
  {
  $id = $r["id"];
  $ftitle = $r["name"];
  if($i == 0 or $i == 3)
  {
  echo "

";
  }
  echo " ";
  echo "";
  echo "show.php?table=photo&id=$fid";
  echo "height=60>
";
  echo "";
  echo "

$ftitle

";
  if($i == 2 or $i == 5)
  {echo " ";}$i++;
  }
}
?>

------解决方案--------------------
都是由于mysql_db_query的执行结果出错的原因

检测mysql_connect("localhost","root","Admin","test"); 是不是有错,[email protected]
还有就是执行的sql出错的可能性比较大。
------解决方案--------------------
$Connid = mysql_connect("localhost","root","Admin");
mysql_select_db("photo");
$sql = "select id,name from photo order by id desc limit $offset,6";
$result = mysql_query($sql);
$num = mysql_num_rows($result); 
这样看看。
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn