Форум программистов, компьютерный форум, киберфорум
PHP для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.55/11: Рейтинг темы: голосов - 11, средняя оценка - 4.55
0 / 0 / 0
Регистрация: 14.06.2014
Сообщений: 19
1

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given

14.06.2014, 20:32. Показов 2251. Ответов 7
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in Z:\home\shop\www\view_cat.php on line 179-это описание ошибки

Код из приложения:
PHP/HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
    $result = mysql_query("SELECT * FROM table_products WHERE visible='1' $querycat ORDER BY $sorting ",$link);
    if (mysql_num_rows($result) > 0)
{
    $row = mysql_fetch_array($result); // Показует что в этих строках!
    
    do
    {
        
if ($row["image"] != "" && file_exists("./uploads_images/".$row["image"]))
{
$img_path =  './uploads_images/'.$row["image"];
$max_width = 150;
$max_height = 150;
 list($width, $height) = getimagesize($img_path);
$ratioh = $max_height/$height;
$ratiow = $max_width/$width;
$ratio = min($ratioh, $ratiow);
$width = intval($ratio*$width);
$height = intval($ratio*$height);
} else
{
$img_path = "/images/noimages80x70.png";
$width = 80;
$height = 70;
}
 
   echo '
   <p>'.$row["title"].'</p>
   
<li>
  <div class="block-images-list">
<img src="'.$img_path.'" width="'.$width.'" height="'.$height.'" />
  </div>
<p class="style-title-list"><a href="">'.$row["title"].'</a></p>
  <ul class="reviews-and-counts-list">
<li><img src="imegas/eye-icon.png" width="20" height="13" /><p>0</p></li>
<li><img src="imegas/comment-icon.png" width="16" height="16" /><p>0</p></li>
  </ul>
 
<a class="add-cart-style-list" ></a>
        <p class="style-price-list" > <strong>'.$row["price"].'</strong>грн.</p>
        <div class="style-text-list">
        '.$row["mini_description"].'
        </div>
</li>
 
    ';
    }
    while ($row = mysql_fetch_array($result));
    }
 
?>
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
14.06.2014, 20:32
Ответы с готовыми решениями:

Ошибка: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given
При сортировке по бренду товара выдает ошибку. Есть блок где сортирует товар по цене и по бренду....

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in on line 42
&lt;?php $tiptonera = isset($_POST) ? $_POST : ''; $vidurobot = isset($_POST) ? $_POST : ''; ...

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given
Здравствуйте! Выдает ошибка Warning: mysql_fetch_array() expects parameter 1 to be resource,...

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in...

7
207 / 199 / 110
Регистрация: 27.12.2010
Сообщений: 819
Записей в блоге: 1
14.06.2014, 20:55 2
Откуда берутся $querycat и $sorting?
До этого кода есть подключение к БД?
visible - текстовое поле? если нет то единицу не надо в кавычках ставить.
0
0 / 0 / 0
Регистрация: 14.06.2014
Сообщений: 19
14.06.2014, 21:19  [ТС] 3
да базу я уже подключил! и начал делать сортировку по параметрам и застрял на этой ошибке
как только создал файл viev_cat.php начало выбивать эту ошибку. В index.php все работает сортировка
применяется, а вот сортировка по параметрам выбеват ошибку
0
207 / 199 / 110
Регистрация: 27.12.2010
Сообщений: 819
Записей в блоге: 1
14.06.2014, 21:21 4
Цитата Сообщение от студент_програм Посмотреть сообщение
В index.php все работает сортировка
применяется, а вот сортировка по параметрам выбеват ошибку
Перед sql запросом напиши echo $sorting;
Выводит то что надо?
0
0 / 0 / 0
Регистрация: 14.06.2014
Сообщений: 19
14.06.2014, 21:26  [ТС] 5
Теперь выдает вот такую ошибку
products_id DESC
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in Z:\home\shop\www\view_cat.php on line 180
0
207 / 199 / 110
Регистрация: 27.12.2010
Сообщений: 819
Записей в блоге: 1
14.06.2014, 21:28 6
Что то не то в sql коде
0
0 / 0 / 0
Регистрация: 14.06.2014
Сообщений: 19
14.06.2014, 21:33  [ТС] 7
Может выложить полность весь код и вы посмотрите может я с переменными что то напортачил?
0
0 / 0 / 0
Регистрация: 14.06.2014
Сообщений: 19
14.06.2014, 22:01  [ТС] 8
PHP/HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php   
    include("include/db_connect.php");
    include("functions/functions.php");
     
    $cat = cler_string($_GET["cat"]); 
    $type = cler_string($_GET["type"]);
    $sorting =  $_GET["sort"];
 
switch ($sorting)
{
    case 'price-ace';
    $sorting = 'price ASC';
    $sort_name = 'От дещовых к дорогим';
    break;
    
    case 'peice-desc';
    $sorting = 'price DESC';
    $sort_name = 'От дорогих к дешовым';
    break;
    
    case 'popular';
    $sorting = 'count DESC';
    $sort_name = 'Популярные';
    break;
    
    case 'news';
    $sorting = 'brand';
    $sort_name = 'Новинки';
    break;
    
    case 'brand';
    $sorting = 'brand';
    $sort_name = 'От А до Я';
    break;
    
    default:
    $sorting = 'products_id DESC';
    $sort_name = 'Без сортировки';
    break;
};
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lans="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
 
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=windows-1251" />
    <link href="css/reset.css" rel="stylesheet" type="text/css" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link href="trackbar/trackbar.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script> 
    <script type="text/javascript" src="/js/jcarousellite_1.0.1.js"></script> 
    <script type="text/javascript" src="/js/shop-script.js"></script>
    <script type="text/javascript" src="/js/jquery.cookie.min.js"></script>
    <script type="text/javascript" src="/trackbar/jquery.trackbar.js"></script>
    <title>Интернет-Магазин Дверной фурнитуры</title>
</head>
 
<body>
 
<div id="block-body">
 
<?php   
    include ("include/block-header.php");
?>
 
<div id="block-right">
<?php
    include ("include/block-category.php");
    include ("include/block-parameter.php");
    include ("include/block-news.php");
?>
</div>
 
<div id="block-content">
<div id="block-sorting">
<p id="nav-breadcrumds"><a href="index.php">Главная страница</a> \ <span>Все товары</span></p>
<ul id="options-list">
<li>Вид: </li>
<li><img id="style-grid" src="imegas/icon-grid.png" width="25" height="25" /></li>
<li><img id="style-list" src="imegas/icon-list.png" width="25" height="25" /></li>
<li>Сортировать</li>
<li><a id="select-sort"><?php echo $sort_name; ?></a></li>
<ul id="sorting-list">
<li><a href="index.php?sort=price-ace" >От дещовых к дорогим</a></li>
<li><a href="index.php?sort=peice-desc" >От дорогих к дешовым</a></li>
<li><a href="index.php?sort=popular" >Популярные</a></li>
<li><a href="index.php?sort=news" >Новинки</a></li>
<li><a href="index.php?sort=brand" >От А до Я</a></li>
</ul>
</ul>
</div>
 
<ul id="block-tovar-grid">
 
<?php
    
   if(!empty($cat) && !empty($type)) 
    {
        $querycat = "AND brand='$cat' AND typе_tovara='$type'";
        
        
        
    }else
    {
        if(!empty ($type))
        {
            $querycat = "AND type_tovara='$type'";
        }else{
           $querycat = ""; 
        }
        
        
    }
    
    
    
    $result = mysql_query("SELECT * FROM table_products WHERE visible=1 '$querycat' ORDER BY $sorting ",$link);
 if (mysql_num_rows($result) > 0) // содержимое ошибки--Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in Z:\home\shop\www\view_cat.php on line 179
{
$row = mysql_fetch_array($result);
    
    do
{
    
if ($row["image"] != "" && file_exists("./uploads_images/".$row["image"]))
{
$img_path =  './uploads_images/'.$row["image"];
$max_width = 200;
$max_height = 200;
 list($width, $height) = getimagesize($img_path);
$ratioh = $max_height/$height;
$ratiow = $max_width/$width;
$ratio = min($ratioh, $ratiow);
$width = intval($ratio*$width);
$height = intval($ratio*$height);
} else
{
$img_path = "/images/no-image.png";
$width = 110;
$height = 200;
}
 
   echo '
   <p>'.$row["title"].'</p>
   
<li>
  <div class="block-images-grid">
<img src="'.$img_path.'" width="'.$width.'" height="'.$height.'" />
  </div>
<p class="style-title-grid"><a href="">'.$row["title"].'</a></p>
  <ul class="reviews-and-counts-grid">
<li><img src="imegas/eye-icon.png" width="20" height="13" /><p>0</p></li>
<li><img src="imegas/comment-icon.png" width="16" height="16" /><p>0</p></li>
  </ul>
 
<a class="add-cart-style-grid" ></a>
        <p class="style-price-grid" > <strong>'.$row["price"].'</strong>грн.</p>
        <div class="mini-features">
        '.$row["mini_features"].'
        </div>
</li>
 
    ';
    }
    while ($row = mysql_fetch_array($result));
    }
    
?>
 
</ul>
 
<ul id="block-tovar-list">
 
<?php
    $result = mysql_query("SELECT * FROM table_products WHERE visible=1 ' $querycat ORDER BY $sorting ",$link);
    if (mysql_num_rows($result) > 0) // содержимое ошибки--Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in Z:\home\shop\www\view_cat.php on line 179
{
    $row = mysql_fetch_array($result);
    
    do
    {
        
if ($row["image"] != "" && file_exists("./uploads_images/".$row["image"]))
{
$img_path =  './uploads_images/'.$row["image"];
$max_width = 150;
$max_height = 150;
 list($width, $height) = getimagesize($img_path);
$ratioh = $max_height/$height;
$ratiow = $max_width/$width;
$ratio = min($ratioh, $ratiow);
$width = intval($ratio*$width);
$height = intval($ratio*$height);
} else
{
$img_path = "/images/noimages80x70.png";
$width = 80;
$height = 70;
}
   echo '
   <p>'.$row["title"].'</p>
   
<li>
  <div class="block-images-list">
<img src="'.$img_path.'" width="'.$width.'" height="'.$height.'" />
  </div>
<p class="style-title-list"><a href="">'.$row["title"].'</a></p>
  <ul class="reviews-and-counts-list">
<li><img src="imegas/eye-icon.png" width="20" height="13" /><p>0</p></li>
<li><img src="imegas/comment-icon.png" width="16" height="16" /><p>0</p></li>
  </ul>
 
<a class="add-cart-style-list" ></a>
        <p class="style-price-list" > <strong>'.$row["price"].'</strong>грн.</p>
        <div class="style-text-list">
        '.$row["mini_description"].'
        </div>
</li>
 
    ';
    }
    while ($row = mysql_fetch_array($result));
    }
 
?>
 
</ul>
 
</div>
 
<?php   
    include ("include/block-footer.php");
?>
 
</div>
 
</body>
</html>
0
14.06.2014, 22:01
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
14.06.2014, 22:01
Помогаю со студенческими работами здесь

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
ВОПРОС ЗАКРЫТ! &lt;?php define ('DB_HOST', 'localhost'); define ('DB_LOGIN', 'root');...

Warning: mysql_fetch_field() expects parameter 1 to be resource, boolean
Привет. У меня установлен Денвер. В папке Z:\home\test1.ru\www файл index.php. Такой код: &lt;html&gt; ...

Warning: fclose() expects parameter to be resource, boolean given in
Хочу установить скрипт на локальном сервере, уже работает сайт На локальном использую xampp и...

Ошибка в коде: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given
Буду благодарен если поможете исправить PHP Warning: mysql_fetch_array() expects parameter 1...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
8
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru