|
-
help pyro or someone ;)
please help, i get this error.....
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/shoutbox/public_html/lukezwebforum/forum.php on line 263
PHP Code:
############################
# GENERAL BOARD ###############
############################
} else if ($action == "general") {
?>
<center>
<form name='general' method='post'>
<table width='95%' cellspacing='2' bgcolor='black' cellpadding='1' border='0'>
<tr><td class='catbg'>
<table width='100%'>
<tr><td width='50%'>
<div align='left'>Welcome, Guest!</div>
</td>
<td width='50%'>
<div align='right'>
<?php print date("G:i:sa , j/m/Y"); ?>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class='windowbg'>
<center>
Lukezweb Forum - <a href='forum.php?action=main'>Home</a> - <a href='forum.php?action=portal'>Portal</a> - <a href=forum.php?action=help'>Help</a>
</center>
</td>
</tr>
<tr>
<td class='windowbg'>General Board</td>
</tr>
<tr><td class='windowbg'><table width='100%' border='0' cellspacing='1' bgcolor='#000000'><tr>
<td colspan='2' class='windowbg2' height='20' align='center' valign='middle'>Topics</td>
<td width='10%' class='windowbg2' align='center' valign='middle' height='20'>Started By</td>
<td width='10%' class='windowbg2' align='center' valign='middle' height='20'>Replies</td>
</tr>
<tr>
<td class='windowbg' colspan='4'>Stickies:</td>
</tr>
<tr>
<td width='10%' class='windowbg' align='center' valign='middle' height='20' onMouseOver="this.style.backgroundColor = '444444'; style.cursor='hand'" onMouseOut="this.style.backgroundColor ='';"><img src=http://geocities.com/lukezwebforum11/new.txt></td>
<td class=windowbg onMouseOver="this.style.backgroundColor = '444444'; style.cursor='hand'" onMouseOut="this.style.backgroundColor ='';"><a href=forum.php?action=post000>Welcome, First Working Thread!</a></td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20' onMouseOver="this.style.backgroundColor = '444444'; style.cursor='hand'" onMouseOut="this.style.backgroundColor ='';">Luke</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20' onMouseOver="this.style.backgroundColor = '444444'; style.cursor='hand'" onMouseOut="this.style.backgroundColor ='';">0</td>
</tr>
</tr>
<tr>
<td class='windowbg' colspan='4'>Topics:</td>
</tr>
<?php
$dbh=mysql_connect ("localhost", "shoutbox_admin", "admin") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("shoutbox_forum");
$querytop = "SELECT `id` , `threadname` , `psotedby` FROM `generaltalk` WHERE 1 AND `id` > 0 ORDER BY `id` DESC LIMIT 0 , 20 ";
$topics = mysql_query($querytop) or die ("Couldn't execute query.");
while ($topics = mysql_fetch_array($topics)) {
$topics = str_replace("\n", "<br>", $topics);
$topics = str_replace("<", "<!--", $topics);
$topics = str_replace(">", "-->", $topics);
$topics = str_replace("\'", "'", $topics);
echo "<tr>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
<img src='http://geocities.com/lukezwebforum11/new.txt'>
</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
".$row['threadname']."
</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
".$row['psotedby']."
</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
0
</td>
</tr>";
}
?>
</table>
</td>
</tr>
</table>
</center>
</form>
<?php
-
Two things that jump out at me.
One is the SQL statement. What is it that you are trying to do? Why did you use WHERE 1 AND `id` > 0.
And the second is the while loop. I would not reuse the variable as you have done, or it will only loop through once.
-
Originally posted by pyro
Two things that jump out at me.
One is the SQL statement. What is it that you are trying to do? Why did you use WHERE 1 AND `id` > 0.
And the second is the while loop. I would not reuse the variable as you have done, or it will only loop through once.
so what should it be?
-
What are you trying to select?
For the while loop, just use two different variables.
-
Originally posted by pyro
What are you trying to select?
For the while loop, just use two different variables.
im trying to do......
SELECT `id` , `threadname` , `psotedby`
FROM `generaltalk`
ORDER BY `id` DESC
LIMIT 0 , 20
and then a way to display them......
Code:
while ($topics = mysql_fetch_array($topics)) {
$topics = str_replace("\n", "<br>", $topics);
$topics = str_replace("<", "<!--", $topics);
$topics = str_replace(">", "-->", $topics);
$topics = str_replace("'", "'", $topics);
echo "<tr>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
<img src='http://geocities.com/lukezwebforum11/new.txt'>
</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
".$row['threadname']."
</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
".$row['psotedby']."
</td>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
0
</td>
</tr>";
}
in that table format but for all values in the table ?
thanks
-
Try running that query instead of the one you had and see if it works better.
-
Originally posted by pyro
Try running that query instead of the one you had and see if it works better.
the one i just posted i had copied and pasted form above? can u show me what u mean?
-
Re: help pyro or someone ;)
They don't look the same to me:
Originally posted by lukezweb
PHP Code:
$querytop = "SELECT `id` , `threadname` , `psotedby` FROM `generaltalk` WHERE 1 AND `id` > 0 ORDER BY `id` DESC LIMIT 0 , 20 ";
Originally posted by lukezweb
SELECT `id` , `threadname` , `psotedby`
FROM `generaltalk`
ORDER BY `id` DESC
LIMIT 0 , 20
-
Re: Re: help pyro or someone ;)
Originally posted by pyro
They don't look the same to me:
oh ok ?
so whats the code then?
sorry am confused :S
-
Try:
PHP Code:
$querytop = "SELECT `id`, `threadname`, `psotedby` FROM `generaltalk` ORDER BY `id` DESC LIMIT 0, 20";
And don't forget to change the name of the variable in your while loop.
-
Originally posted by pyro
Try:
PHP Code:
$querytop = "SELECT `id`, `threadname`, `psotedby` FROM `generaltalk` ORDER BY `id` DESC LIMIT 0, 20";
And don't forget to change the name of the variable in your while loop.
ok i got this to work 
i have another questions how can you get the number of rows in and sql table ?
so in a table containing posts by one board, you can say on the boards index page, how many posts (rows) are on that board
-
-
ah thanks but i get this.....
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/shoutbox/public_html/lukezwebforum/forum.php on line 215
-
How are you trying to use it?
-
Originally posted by pyro
How are you trying to use it?
u want to se the full code?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|
Bookmarks