salikov
Новичок
Дата регистрации:
17.01.2013 20:35:11
Сообщений: 5
Warning: mysql_num_rows() expects parameter 1 to be resource, null given in S:\home\sary-su.local\www\home.php on line 155
Такой статьи нет!
<?php
include '/bd.php';
$category_id = (int)$_GET['category_id'];
// получаем название категории
$res_category = mysql_query("SELECT `name` FROM `category` WHERE
`category_id`='{$category_id}'"
$row_category = mysql_fetch_assoc($res_category);
if (isset($_COOKIE['auto']) and isset($_COOKIE['login']) and isset($_COOKIE['password']))
{//если есть необходимые переменные
if ($_COOKIE['auto'] == 'yes') { // если пользователь желает входить автоматически, то запускаем сессии
$_SESSION['password']=strrev(md5($_COOKIE['password']))."b3p6f"; //в куках пароль был не зашифрованный, а в сессиях обычно храним зашифрованный
$_SESSION['login']=$_COOKIE['login'];//сессия с логином
$_SESSION['id']=$_COOKIE['id'];//идентификатор пользователя
}
}
if (!empty($_SESSION['login']) and !empty($_SESSION['password']))
{
//если существет логин и пароль в сессиях, то проверяем их и извлекаем аватар
$login = $_SESSION['login'];
$password = $_SESSION['password'];
$result = mysql_query("SELECT id,avatar FROM users WHERE login='$login' AND password='$password' AND activation='1'",$db);
$myrow = mysql_fetch_array($result);
//извлекаем нужные данные о пользователе
$monthes = array('01' => 'январь',
'02' => 'февраль',
'03' => 'март',
'04' => 'апрель',
'05' => 'май',
'06' => 'июнь',
'07' => 'июль',
'08' => 'август',
'09' => 'сентябрь',
'10' => 'октябрь',
'11' => 'нобрь',
'12' => 'декабрь');
$start_date = $date."-01";
$end_date = $date."-31";
$date_format = explode("-",$date);
}
function pages(){
$query = "SELECT page_id, title FROM pages ORDER BY position";
$res = mysql_query($query);
$pages = array();
while($row = mysql_fetch_assoc($res)){
$pages[] = $row;
}
return $pages;
}
/* ===Страницы=== */
/* ===Отдельная страница=== */
function get_page($page_id){
$query = "SELECT title, text FROM pages WHERE page_id = $page_id";
$res = mysql_query($query);
$get_page = array();
$get_page = mysql_fetch_assoc($res);
return $get_page;
}
$pages = pages();
$page_id = abs((int)$_GET['page_id']);
$get_page = get_page($page_id);
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.0.0.58475 -->
<meta charset="utf-8">
<title>Home</title>
<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" href="style.css" media="screen">
<!--[if lte IE 7]><link rel="stylesheet" href="style.ie7.css" media="screen" /><![endif]-->
<link rel="stylesheet" href="style.responsive.css" media="all">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Abril+Fatface&subset=latin">
<script src="jquery.js"></script>
<script src="script.js"></script>
<script src="script.responsive.js"></script>
<script type="text/javascript" src="scripts/jquery-1.4.3.min.js"></script> <script type="text/javascript" src="scripts/fancybox/jquery.mousewheel-3.0.4.pack.js"></script> <script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="scripts/fancybox/jquery.fancybox-1.3.4.css" media="screen" /> <script type="text/javascript"> $(document).ready(function(){ $("a.photo".fancybox({
}); }); </script> <style type="text/css"> *{margin:0; padding:0;} body{background-color:#2C2E2F; color:#fff; font-family:Verdana, Arial; font-size:13px;} #wrapper{width:920px; margin:0 auto;} #header{text-align:center;} #content{border-top:1px solid #888; border-bottom:1px solid #888; padding:20px;} #nav{padding:10px; text-align:center;} img{border:3px solid #fff; margin:5px;} .category{width:100%; margin-bottom:20px;} h3{text-align:center;} </style>
<style>.art-content .art-postcontent-0 .layout-item-0 { border-top-width:1px;border-top-style:dotted;border-top-color:#BFBFBF;margin-top: 10px;margin-bottom: 10px; }
.art-content .art-postcontent-0 .layout-item-1 { padding-right: 10px;padding-left: 10px; }
.ie7 .post .layout-cell {border:none !important; padding:0 !important; }
.ie6 .post .layout-cell {border:none !important; padding:0 !important; }
</style></head>
<body>
<div id="art-main">
<header class="art-header clearfix">
<div class="art-shapes">
<div class="art-object1911514272" data-left="50%"></div>
</div>
</header>
<nav class="art-nav clearfix">
<ul class="art-hmenu"><li><a href="<?=home.php?>">Главная</a></li>
<?php if($pages): ?>
<?php foreach($pages as $item): ?>
<li><a href="page.php?page_id=<?=$item['page_id']?>"><?=$item['title']?></a></li>
<?php endforeach; ?>
<?php endif; ?>></li></ul>
</nav>
<div class="art-sheet clearfix">
<div class="art-layout-wrapper clearfix">
<div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell art-sidebar1 clearfix"><div class="art-vmenublock clearfix">
<div class="art-vmenublockcontent">
<ul class="art-vmenu"><li><a href="home.html" class="active">Категори</a><?php
$category_id = (int)$_GET['category_id'];
$res = mysql_query("SELECT * FROM `category`" or die(mysql_error());
while($row = mysql_fetch_assoc($res)){
echo '<li><a href="'.$sait_url.'articles.php?category_id='.$row['category_id'].
'">' .$row['name']. '</a></li>';
}
?></li></ul>
</div>
</div><div class="art-block clearfix">
<div class="art-blockcontent"><p>Enter content here...</p>
<br>
<p><input type="text" value="Text..."></p>
<p style="margin-top: 5px"><label class="art-checkbox"><input value="" type="checkbox">Lorem ipsum dolor.</label></p>
<p style="margin-top: 5px"><label class="art-radiobutton"><input value="" type="radio" name="rg">Text...</label> <label class="art-radiobutton"><input value="" type="radio" name="rg">Text...</label></p>
<p style="margin-top: 5px"><a href="#" class="art-button">Send</a></p></div>
</div></div>
<div class="art-layout-cell art-content clearfix"><article class="art-post art-article">
<div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
<div class="art-content-layout-row"><div class="art-layout-cell layout-item-1" style="width: 50%" >
<h3 style="border-bottom: 1px dotted #BFBFBF; padding-bottom: 5px">
<?php
if(mysql_num_rows($res_article) > 0){ $views = $row_article['views'] + 1; $res = mysql_query("UPDATE `articles` SET `views`='{$views}' WHERE `article_id`='{$article_id}'" echo "<span class='view_article'><h1>{$row_article['title']}</h1></span>"; echo $row_article['content'];
echo "<div class='view_article_date'><strong>Дата</strong>: {$row_article['date']} | <strong>Просмотров</strong>: {$views}</div>"; }else echo 'Такой статьи нет!';
?>[/color] </h3>
</div>
</div>
</div>
<div class="art-content-layout-br layout-item-0">
</div><div class="art-content-layout">
<div class="art-content-layout-row"></div>
</div>
</div>
</article></div>
<div class="art-layout-cell art-sidebar2 clearfix"><div class="art-block clearfix">
<div class="art-blockcontent"><div>
<form action="#" class="art-search" method="get" name="searchform">
<input type="text" value="" name="s" />
<input type="submit" value="Search" name="search" class="art-search-button" />
</form>
</div></div>
</div><div class="art-block clearfix">
<div class="art-blockcontent"><form action="#" method="post" name="login" id="form-login">
<fieldset class="input" style="border: 0 none;">
<p id="form-login-username">
<label for="modlgn_username">Username</label>
<br />
<input id="modlgn_username" type="text" name="username" class="inputbox" alt="username" size="18" />
</p>
<p id="form-login-password">
<label for="modlgn_passwd">Password</label>
<br />
<input id="modlgn_passwd" type="password" name="passwd" class="inputbox" size="18" alt="password" />
</p>
<p id="form-login-remember">
<label class="art-checkbox">
<input type="checkbox" id="modlgn_remember" name="remember" value="yes" alt="Remember Me" />Remember Me
</label>
</p>
<input type="submit" value="Login" name="Submit" class="art-button" />
</fieldset>
<ul>
<li>
<a href="#">Forgot your password?</a>
</li>
<li>
<a href="#">Forgot your username?</a>
</li>
<li>
<a href="#">Create an account</a>
</li>
</ul>
</form></div>
</div><div class="art-block clearfix">
<div class="art-blockcontent"><div>
<ul>
<li>
<a href="#">My first blog</a>
</li>
<li>
<a href="#">Who will prevail?</a>
</li>
<li>
<a href="#">Stay positive!</a>
</li>
<li>
<a href="#">Oil still going up</a>
</li>
<li>
<a href="#">Gripes and Grins</a>
</li>
<li>
<a href="#">2012 Olympics</a>
</li>
<li>
<a href="#">How to SEO</a>
</li>
<li>
<a href="#">On Global Warming</a>
</li>
<li>
<a href="#">Can you guess?</a>
</li>
</ul>
</div></div>
</div><div class="art-block clearfix">
<div class="art-blockcontent"><div>
<p>Lorem ipsum dolor sit amet. Nam sit amet sem. Mauris a ante.</p>
<ul>
<li>
<a href="#" title="All News">All News</a> (50)
</li>
<li>
<a href="#" title="Best of the Year">Best of the Year</a> (4)
</li>
<li>
<a href="#" title="Hyperlink">Hyperlink</a> (24)
</li>
<li>
<a href="#" title="Visited link" class="visited">Visited link</a> (17)
</li>
<li>
<a href="#" title="Hovered link" class="hover">Hovered link</a> (6)
</li>
</ul>
</div></div>
</div><div class="art-block clearfix">
<div class="art-blockcontent"><div>
<ul>
<li>
<a href="#" title="November 2008">November 2008</a>
</li>
<li>
<a href="#" title="October 2008">October 2008</a>
</li>
<li>
<a href="#" title="September 2008">September 2008</a>
</li>
<li>
<a href="#" title="June 2008">June 2008</a>
</li>
</ul>
</div></div>
</div></div>
</div>
</div>
</div>
</div>
<footer class="art-footer clearfix">
<div class="art-footer-inner">
<p><a href="#">Link1</a> | <a href="#">Link2</a> | <a href="#">Link3</a></p>
<p>Copyright © 2014. All Rights Reserved.</p>
</div>
</footer>
</div>
</body></html>
Ошибку выделил большим шрифтом