Davie33 Posted June 22, 2012 Share Posted June 22, 2012 Hi am having a problem with this error i am seeing and dont know why. This is my error...Warning: mysql_fetch_row() expects parameter 1 to be resource, null given in C:\wamp\www\ydiycomputers\inc\includes.php on line 8 <?php if (isset($_GET['page'])) { $pageno = ($_GET['page']); } else { $pageno = 1; } $query = "SELECT count(id) FROM items WHERE category = 'id'"; $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; $rows_per_page = 5; $lastpage = CEIL($numrows/$rows_per_page); $pageno = (int)$pageno; IF ($pageno < 1) { $pageno = 1; } ELSEIF ($pageno > $lastpage) { $pageno = $lastpage; } $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php ECHO $urlpath;?>template/style/style.css" /> <link rel="stylesheet" type="text/css" href="<?php ECHO $urlpath;?>template/style/home.css" /> <link rel="stylesheet" type="text/css" href="<?php ECHO $urlpath;?>template/style/cats.css" /> <?php SWITCH($_GET['act']){ CASE 'cats': $query = mysql_query("SELECT * FROM `cats` WHERE id = 'id'"); $row = mysql_fetch_array($query); ?> <title><?php ECHO $sitedomain;?> - <?php ECHO $row['catname']; ?></title> <?php BREAK; DEFAULT:?> <title><?php ECHO $sitedomain;?> - <?php ECHO $slogan;?></title> <?php BREAK; } ?> </head> Link to comment https://forums.phpfreaks.com/topic/264620-mysql_fetch_row-help-plz/ Share on other sites More sharing options...
mikosiko Posted June 22, 2012 Share Posted June 22, 2012 you are not executing the query ($query), hence $result doesn't exist Link to comment https://forums.phpfreaks.com/topic/264620-mysql_fetch_row-help-plz/#findComment-1356168 Share on other sites More sharing options...
The Little Guy Posted June 22, 2012 Share Posted June 22, 2012 I usually get that when my query is invalid. I also see you don't have "mysql_query" in the code either Link to comment https://forums.phpfreaks.com/topic/264620-mysql_fetch_row-help-plz/#findComment-1356171 Share on other sites More sharing options...
Davie33 Posted June 22, 2012 Author Share Posted June 22, 2012 you are not executing the query ($query), hence $result doesn't exist so it sould be like this ? $result= "SELECT count(id) FROM items WHERE category = 'id'"; $query_data = mysql_fetch_row($result); Link to comment https://forums.phpfreaks.com/topic/264620-mysql_fetch_row-help-plz/#findComment-1356174 Share on other sites More sharing options...
Davie33 Posted June 22, 2012 Author Share Posted June 22, 2012 I usually get that when my query is invalid. I also see you don't have "mysql_query" in the code either I didnt even notice that thanks for that Link to comment https://forums.phpfreaks.com/topic/264620-mysql_fetch_row-help-plz/#findComment-1356175 Share on other sites More sharing options...
Davie33 Posted June 22, 2012 Author Share Posted June 22, 2012 Thank you got it sorted thanks guys. Link to comment https://forums.phpfreaks.com/topic/264620-mysql_fetch_row-help-plz/#findComment-1356176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.