我最近將一個PHP站點遷移到了我的服務器,並在遷移後收到此錯誤消息。由於我不熟悉PHP,我非常感謝任何幫助。謝謝。警告:strpos()期望參數1是字符串,資源
警告:strpos()預計參數1是串,在給定的 ... /的public_html /存儲/product_list.php線121上121
行如下資源...
$exists = (strpos($handle, "Resource id") !== false) ? true : false;
下面是關於相關性頁面頂部的其餘代碼。
<?php session_start();
include_once("../includes/define.inc.php");
include("../includes/common.php");
include("../includes/mysql_functions.php");
if(isset($_GET['category']))
{
$exists = checkIfExists("aw_category", "aw_category_urlalias='". $_GET['category']."'", "aw_category_id");
if(!$exists)
{
header("Location: " . PRODUCT_LIST);
}
}
$get_category = (isset($_GET['category'])) ? $_GET['category'] : "";
$category_id = ($get_category == "") ? "" : getCategoryIDByAlias($get_category);
$get_page = (isset($_GET['page'])) ? $_GET['page'] : 0;
/*category menu*/
$qry_cat = "SELECT aw_category_urlalias, aw_category_id,aw_category_name,aw_category_order,aw_category_status FROM aw_category WHERE aw_category_status = 1 ORDER BY aw_category_order asc";
$result_cat = Query($qry_cat);
/*product*/
$qry_pro = "SELECT *
FROM aw_product
INNER JOIN aw_category
ON aw_product.aw_product_category = aw_category.aw_category_id
INNER JOIN aw_image
ON aw_product.aw_product_id = aw_image.aw_img_prodid
WHERE aw_product.aw_product_status = 1";
if($category_id == "")
{ //Feature Product
$qry_pro .= " AND aw_product.aw_product_category = 1";
} else {
$qry_pro .= " AND aw_product.aw_product_category = ".$category_id."";
}
$qry_pro .= " GROUP BY aw_product.aw_product_id
ORDER BY aw_product.aw_product_priority desc,aw_product.aw_product_date desc";
if($get_category=="")
{ //Feature Product
$qry_pro .= " LIMIT 6";
}
$result_pro = Query($qry_pro);
//$row_pro = mysql_fetch_array($result_pro);
$result_pro2 = Query($qry_pro);
if(!$get_category == "")
{
/*Pagination*/
$num_per_page= 12;
$num_rows = mysql_num_rows($result_pro);
$num_pages = ceil($num_rows/$num_per_page);
$nav = "";
$begin = $get_page * $num_per_page;
$qry_pro .= " LIMIT " . $begin . ",12";
$result_pro = Query($qry_pro);
$row_pro = mysql_fetch_array($result_pro);
if($get_page > 0)
{
$nav ="<a class=\"page_a\" href=\"".PRODUCT_LIST."?category=".$get_category."&page=".($get_page-1)."\">« Previous</a> | ";
}
for($p=0;$p<$num_pages;$p++)
{
if($get_page == $p)
$nav .="<a class=\"page_a\" style='text-decoration:underline' href=\"".PRODUCT_LIST."?category=".$get_category."&page=".$p."\">".($p+1)."</a> | ";
else
$nav .="<a class=\"page_a\" href=\"".PRODUCT_LIST."?category=".$get_category."&page=".$p."\">".($p+1)."</a> | ";
}
if($get_page<$num_pages-1)
{
$nav .="<a class=\"page_a\" href=\"".PRODUCT_LIST."?category=".$get_category."&page=".($get_page+1)."\"> Next »</a>";
}
}//-------
/*news*/
$qry_news = "SELECT aw_news_title FROM aw_news ORDER BY aw_news_date desc LIMIT 8";
$result_news = Query($qry_news);
function getCategoryIDByAlias($alias)
{
$query = "SELECT aw_category_id FROM aw_category WHERE aw_category_urlalias='".$alias."'";
$rs = Query($query);
$row = mysql_fetch_array($rs);
return $row['aw_category_id'];
}
function checkIfThumbExists($thumb)
{
//$exists = (file_exists($img_src_thumb)) ? true : false;
//echo $exists;
//$exists = (is_file($img_src_thumb) ) ? true : false;
//echo $exists;
//$AgetHeaders = @get_headers($img_src_thumb);
//$exists = (preg_match("|200|", $AgetHeaders[0])) ? true : false;
//echo $exists;
//$header_response = get_headers($img_src_thumb, 1);
//$exists = (strpos($header_response[0], "404") !== false) ? false : true;;
//echo $exists;
$handle = @fopen($thumb, 'r');
$exists = (strpos($handle, "Resource id") !== false) ? true : false;
if($exists)
{
$size = getimagesize($thumb);
if($size[3] == 'width="214" height="214"')
{
$exists = true;
} else {
$exists = false;
}
}
return $exists;
}
?>
'$ exists =(strpos($ handle,「Resource id」)!== false)? true:false;'WAT?!? - 爲什麼不只是測試一個布爾錯誤? RTFM! –