php - Warning: mysql_fetch_array() expects parameter 1 to be resource sql -
i'm having trouble inserting new post in database. ran on shared host , there no problem, on vps gives me following error:
warning: mysql_fetch_array() expects parameter 1 resource, boolean given in /home/sam/public_html/admin/include/functions.php on line 37 warning: mysql_fetch_array() expects parameter 1 resource, boolean given in /home/sam/public_html/admin/include/functions.php on line 46 warning: mysql_fetch_array() expects parameter 1 resource, boolean given in /home/sam/public_html/admin/include/functions.php on line 55
here code (functions.php) :
<?php include("../../connections/confing.php"); function offset_time($time,$ofset) { $time_array = explode(":",$time); $am = ""; $hours = $time_array[0]; $minutes = $time_array[1]; $new_hour = $hours +10; if($new_hour>24){ $new_hour = $new_hour - 24; $am = "am"; }else{ $am = "pm"; } if ($new_hour>12){ $new_hour = $new_hour -12; } $offset_time = $new_hour . ":". $minutes ." ".$am ; return $offset_time; } //---------------------- cat id ------------------------------------------- function getcatid($newsid){ $minsql = "select catid art_news newsid=".$newsid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $catid = $rsget["catid"]; return $catid; } function getzoneid($newsid){ $minsql = "select zoneid art_news newsid=".$newsid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $zoneid = $rsget["zoneid"]; return $zoneid; } function get_news_lang($newsid){ $minsql = "select lang art_news newsid=".$newsid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $lang = $rsget["lang"]; return $lang; } function get_art_lang($artid){ $minsql = "select lang art_articles artid=".$artid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $lang = $rsget["lang"]; return $lang; } function get_video_lang($albumid){ $minsql = "select lang video_albums albumid=".$albumid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $lang = $rsget["lang"]; return $lang; } function get_gallery_lang($albumid){ $minsql = "select lang glr_albums albumid=".$albumid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $lang = $rsget["lang"]; return $lang; } function getphoto_newsid($photoid){ $minsql = "select newsid art_photos photoid=".$photoid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $newsid = $rsget["newsid"]; return $newsid; } function get_photo_albumid($photoid){ $minsql = "select albumid glr_photos photoid=".$photoid; $rsofget = mysql_query($minsql); $rsget = mysql_fetch_array($rsofget); $albumid = $rsget["albumid"]; return $albumid; } ?>
you should provide valid sql results resource first parameter (mysql_query return false in case of error):
<?php mysql_connect("localhost", "user", "password") or die("connect error: " . mysql_error()); mysql_select_db("mydb"); $sqlresource = mysql_query("select id, name mytable"); if ($sqlresource === false) // check if query return error die("query error: " . mysql_error()); while ($row = mysql_fetch_array($sqlresource, mysql_num)) { printf("id: %s name: %s", $row[0], $row[1]); } mysql_free_result($sqlresource); ?>
ps: mysql* functions ares deprecated, use mysqli or better pdo extensions.
Comments
Post a Comment