/    Sign up×
Community /Pin to ProfileBookmark

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

[code=php]
############################
# 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’>

</td>
</tr>”;
}
?>
</table>
</td>
</tr>
</table>
</center>
</form>
<?php
[/code]

to post a comment
PHP

19 Comments(s)

Copy linkTweet thisAlerts:
@pyroDec 17.2003 — 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.
Copy linkTweet thisAlerts:
@lukezwebauthorDec 17.2003 — [i]Originally posted by pyro [/i]

[B]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. [/B]
[/QUOTE]



so what should it be?
Copy linkTweet thisAlerts:
@pyroDec 17.2003 — What are you trying to select?

For the while loop, just use two different variables.
Copy linkTweet thisAlerts:
@lukezwebauthorDec 17.2003 — [i]Originally posted by pyro [/i]

[B]What are you trying to select?



For the while loop, just use two different variables. [/B]
[/QUOTE]


im trying to do......

SELECT id , threadname , psotedby

FROM generaltalk

ORDER BY id DESC

LIMIT 0 , 20

and then a way to display them......


<i>
</i>while ($topics = mysql_fetch_array($topics)) {
$topics = str_replace("n", "&lt;br&gt;", $topics);
$topics = str_replace("&lt;", "&lt;!--", $topics);
$topics = str_replace("&gt;", "--&gt;", $topics);
$topics = str_replace("'", "'", $topics);
echo "&lt;tr&gt;
&lt;td width='10%' class='windowbg' align='center' valign='middle' height='20'&gt;
&lt;img src='http://geocities.com/lukezwebforum11/new.txt'&gt;
&lt;/td&gt;
&lt;td width='10%' class='windowbg' align='center' valign='middle' height='20'&gt;
".$row['threadname']."
&lt;/td&gt;
&lt;td width='10%' class='windowbg' align='center' valign='middle' height='20'&gt;
".$row['psotedby']."
&lt;/td&gt;
&lt;td width='10%' class='windowbg' align='center' valign='middle' height='20'&gt;

&lt;/td&gt;
&lt;/tr&gt;";
}




in that table format but for all values in the table ?

thanks ?
Copy linkTweet thisAlerts:
@pyroDec 17.2003 — Try running that query instead of the one you had and see if it works better.
Copy linkTweet thisAlerts:
@lukezwebauthorDec 17.2003 — [i]Originally posted by pyro [/i]

[B]Try running that query instead of the one you had and see if it works better. [/B][/QUOTE]




the one i just posted i had copied and pasted form above? can u show me what u mean?
Copy linkTweet thisAlerts:
@pyroDec 17.2003 — They don't look the same to me:

[i]Originally posted by lukezweb

[/i]

[code=php]$querytop = "SELECT id , threadname , psotedby FROM generaltalk WHERE 1 AND id > 0 ORDER BY id DESC LIMIT 0 , 20 ";[/code][/QUOTE]


[i]Originally posted by lukezweb [/i]

SELECT id , threadname , psotedby

FROM generaltalk

ORDER BY id DESC

LIMIT 0 , 20
[/QUOTE]
Copy linkTweet thisAlerts:
@lukezwebauthorDec 17.2003 — [i]Originally posted by pyro [/i]

[B]They don't look the same to me: [/B][/QUOTE]



oh ok ?


so whats the code then? ?


sorry am confused :S
Copy linkTweet thisAlerts:
@pyroDec 17.2003 — Try:

[code=php]$querytop = "SELECT id, threadname, psotedby FROM generaltalk ORDER BY id DESC LIMIT 0, 20";[/code]

And don't forget to change the name of the variable in your while loop.
Copy linkTweet thisAlerts:
@lukezwebauthorDec 18.2003 — [i]Originally posted by pyro [/i]

[B]Try:



[code=php]$querytop = "SELECT id, threadname, psotedby FROM generaltalk ORDER BY id DESC LIMIT 0, 20";[/code]

And don't forget to change the name of the variable in your while loop. [/B][/QUOTE]



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 ?
Copy linkTweet thisAlerts:
@pyroDec 18.2003 — [URL=http://us4.php.net/manual/en/function.mysql-num-rows.php]mysql_num_rows()[/URL] ?
Copy linkTweet thisAlerts:
@lukezwebauthorDec 18.2003 — [i]Originally posted by pyro [/i]

[B][URL=http://us4.php.net/manual/en/function.mysql-num-rows.php]mysql_num_rows()[/URL] ? [/B][/QUOTE]



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
Copy linkTweet thisAlerts:
@pyroDec 18.2003 — How are you trying to use it?
Copy linkTweet thisAlerts:
@lukezwebauthorDec 18.2003 — [i]Originally posted by pyro [/i]

[B]How are you trying to use it? [/B][/QUOTE]



u want to se the full code?
Copy linkTweet thisAlerts:
@pyroDec 18.2003 — No, just the bit that would show me how you use mysal_num_rows, please.
Copy linkTweet thisAlerts:
@lukezwebauthorDec 18.2003 — [i]Originally posted by pyro [/i]

[B]No, just the bit that would show me how you use mysal_num_rows, please. [/B][/QUOTE]



ok.......

[code=php]
############################
# GENERAL BOARD ###############
############################


} else if ($action == "general") {
$link = mysql_connect("localhost", "shoutbox_admin", "admin");
mysql_select_db("shoutbox_forum", $link);
$result = mysql_query("SELECT * FROM posts001", $link);
$num_rows = mysql_num_rows($result);
?>
<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 class='windowbg2' align='center' valign='middle' height='20'>
Started By
</td>
<td class='windowbg2' align='center' valign='middle' height='20'>
Replies
</td>
</tr>
<tr>
<td class='windowbg' colspan='4'>Stickies:</td>
</tr>
<tr>
<td class='windowbg' align='center' valign='middle' height='20' onMouseOver="this.style.backgroundColor = '444444'; style.cursor='hand'" onMouseOut="this.style.backgroundColor ='';"><img src=white.gif></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 class='windowbg' align='center' valign='middle' height='20' onMouseOver="this.style.backgroundColor = '444444'; style.cursor='hand'" onMouseOut="this.style.backgroundColor ='';">Luke</td>
<td 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

$query = "SELECT id , threadname , psotedby FROM generaltalk WHERE 1 AND id > 0 ORDER BY id LIMIT 0 , 20 ";
$result = mysql_query($query) or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
$row = str_replace("n", "<br>", $row);
$row = str_replace("<", "<!--", $row);
$row = str_replace(">", "-->", $row);
$row = str_replace("'", "'", $row);
echo "<tr>
<td width='10%' class='windowbg' align='center' valign='middle' height='20'>
<img src=white.gif>
</td>
<td width='50%' class='windowbg' align='center' valign='middle' height='20'>
".$row['threadname']."
</td>
<td width='20%' class='windowbg' align='center' valign='middle' height='20'>
".$row['psotedby']."
</td>
<td width='20%' class='windowbg' align='center' valign='middle' height='20'>
$num_rows
</td>
</tr>";
}
?>
</table>
</td>
</tr>
</table>
</center>
</form>
<?php



[/code]
Copy linkTweet thisAlerts:
@pyroDec 18.2003 — is posts001 the name of your table?
Copy linkTweet thisAlerts:
@lukezwebauthorDec 19.2003 — [i]Originally posted by pyro [/i]

[B]is posts001 the name of your table? [/B][/QUOTE]



yes ?
Copy linkTweet thisAlerts:
@pyroDec 19.2003 — Hmm... everything looks right. That's why I asked if posts001 was your table - it sounded more like an entry ID or something, which would cause it not to work.
×

Success!

Help @lukezweb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...