PHP的另一个问题 [英] Another Problem With PHP
本文介绍了PHP的另一个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
警告:mysql_fetch_assoc()期望参数1为资源,在第21行的C:\ Program Files \ xampp \ htdocs \ ZA_Kamez \ include.php中给出布尔值
此错误是什么意思?
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\xampp\htdocs\ZA_Kamez\include.php on line 21
What does this error mean??
<?php
include 'blogpost.php';
$connection = mysql_connect('localhost', 'login_h', '1234') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>");
$database = "articles";
mysql_select_db($database, $connection) or die ("<p class='error'>Sorry, we were unable to connect to the database.</p>");
function GetBlogPosts($inId=null, $inTagId =null)
{
$query = null;
if (!empty($inId))
{
$query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC");
}
else
{
$query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC");
}
$postArray = array();
while ($row = mysql_fetch_assoc($query))
{
$myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_up']);
array_push($postArray, $myPost);
}
return $postArray;
}
?>
推荐答案
连接 = mysql_connect(' localhost',' ' 或死亡( < p class ='error'>很抱歉,我们无法</p>");
connection = mysql_connect('localhost', 'login_h', '1234') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>");
数据库 = " ; mysql_select_db(
database = "articles"; mysql_select_db(
数据库,
这篇关于PHP的另一个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文