PHP Error

Status
Not open for further replies.

iShaddic

New Member
Mar 19, 2012
6
0
Error given:
Code:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/****/public_html/forum.php on line 7
PHP Code:
PHP:
$_ROWS = mysql_num_rows ($_CATEGORIES);

Full PHP Code:
PHP:


<?php
include("Header.php");
mysql_query("update Members set myLocation = '".$_SERVER['PHP_SELF']."' where ID = '".$userRow['ID']."'");

$_CATEGORIES = mysql_query("SELECT * FROM `Forums` ORDER BY `Id` ASC");
$_ROWS = mysql_num_rows ($_CATEGORIES);
?>
<div id='container'>
<center>
<br />
<div style='width: 90%; text-align: left; font-size: 10pt; border: 1px gray solid; background-color: #CCC; color: gray; padding: 6px;'>
<table id='forum' width='90%'>
<tr style='width: 100%; text-align: left; font-size: 10pt; border: 1px black solid; background-color: #DDD; color: gray; padding: 6px;'>
<td width='400' style='padding: 6px;'>
Category
</td>
<td width='100' style='padding: 6px;'>
Last Poster
</td>
<td width='100' style='padding: 6px;'>
Post Count
</td>
</tr>
<?php
for($x = 1; $x <= $_ROWS; $x++) {
$_ROW = mysql_fetch_array($_CATEGORIES);
$_POST_COUNT = mysql_num_rows(mysql_query("SELECT * FROM `ForumThreads` WHERE `category`='$_ROW[ID]'"));
if($_ROW['Name'] != "[sep]") {
?>




WHY IT NO WORK?​
Page:
 

Heaplink

Developer & Designer
Nov 9, 2011
510
173
This means that the mysql query has an syntax error.

A few things you can do to make your code better and easier to read:
1. Do NOT use $_(name) variables. Usually $_ is PHP/Zend global variables.
2. Use ` (apostrophe) when you make queries e.g. mysql_query("UPDATE `Members` SET `myLocation` = '".$_SERVER['PHP_SELF']."' WHERE `ID` = '".$userRow['ID']."'");
3. Keep tables and columns in database lowercase, easier to read when you make queries.
4. Keep query syntax uppercase like above.
 
Status
Not open for further replies.

Users who are viewing this thread

Top