Hi, I'm struggling to get a relatively simple PHP/MySQL script to work. Basically, I've got two tables populated with entries from a database.
PHP ver: 5.2.6
apache ver:2.2.9
Mysql ver:5.0.51b
However I'm getting errors on the second table:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/server/apache/htdocs/board.php on line 23
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/server/apache/htdocs/board.php on line 44
board.php code table:
16 <?php
17 //DB connect
18 include "dbconn.inc";
19
20 //select
21 $query = "SELECT * FROM 'freeboard' where'is_comment' = 0 order by 'thread' desc";
22 $result = mysql_query($query, $dbconn);
23 $total = mysql_num_rows($result);
24
25 //paging
26 $page = $_GET[page];
27 $list_scale = 10;
28 $page_scale = 10;
29 if(!$page) {$page = 1;}
30 $total_pages = ceil($total/$list_scale);
31 $start = ($page-1)*$list_scale;
32 if($total_pages > 1)
33 {
34 $page_count = ceil($page/$page_scale);
35 $start_page = ($page_count-1)*$page_scale+1;
36 $end_page = $start_page + $page_scale-1;
37 if($end_page > $total_pages){
38 $end_page = $total_pages;
39 }}
40
41 $query = "SELECT * FROM 'freeboard' where'is_comment' = 0 order by 'thread'desc limit $start, $list_scale";
42 $result = mysql_query($query, $dbconn);
43
44 for($i=$total-(($page-1)*$list_scale); $list=mysql_fetch_array($result); $i--){
45
46 //reply  
47 $reply = "";
48 $reply2 = "";
49 for($a = 0; $a < $list[depth]; $a++)
50 $reply.=" ";
51 if($list[depth] > 0)
52 $repy2 = "[reply]";
53 if($list[comment_num] > 0)
54 $list[title].="($list[comment_num])";
Database Table:
+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| idx | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| passwd | varchar(20) | NO | | NULL | |
| title | varchar(80) | NO | | NULL | |
| date | varchar(10) | NO | | NULL | |
| time | varchar(8) | NO | | NULL | |
| hit | int(11) | NO | | NULL | |
| contents | text | NO | MUL | NULL | |
| thread | int(11) | NO | UNI | NULL | |
| depth | int(11) | NO | | NULL | |
| is_comment | int(11) | NO | | NULL | |
| parent_thread | int(11) | NO | | NULL | |
| comment_num | int(11) | NO | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
13 rows in set (0.00 sec)