Jump to content


Photo

Not reporting data


  • Please log in to reply
3 replies to this topic

#1 IEMC

IEMC
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationMichigan (USA)

Posted 24 March 2006 - 10:18 PM

This is a news system.

Its one i made a while back, stopped doing stuff with websites for awhile, now im coming back to it.

My code is:
<?php    
        $table = 'news';

        $dbconnection = mysql_connect("$host", "$user", "$pass") or die ("MySQL Connection Attempt Failed: " . mysql_error());
       mysql_select_db("$database",$dbconnection);
        

            $query="SELECT * FROM $table ORDER BY post_numb DESC LIMIT 1";
            $result=mysql_query($query);
            $num_rows=mysql_num_rows($result);
             $i=0;
            while($i<$num_rows) {
            $title=mysql_result($result,$i,'news_title');
            $time=mysql_result($result,$i,'time');
            $article=mysql_result($result,$i,'news_text');
            
            echo "$title";
              echo nl2br("$article"); 
            $i=$i+1;
            }
            mysql_close( $dbconnection );
        ?>

I have news entered, its just whenever i try to see the news, i get this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/.invitation/lukepolito/mrfaxsender.be/index.php on line 30[/quote]

Which makes no sense, because this used to work. Whats the problem?

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 24 March 2006 - 11:28 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
$table = 'news';

$dbconnection = mysql_connect("$host", "$user", "$pass") or die ("MySQL Connection Attempt Failed: " . mysql_error());
mysql_select_db("$database",$dbconnection);


$query="SELECT * FROM $table ORDER BY post_numb DESC LIMIT 1";
$result=mysql_query($query) or DIE(mysql_error());
$num_rows=mysql_num_rows($result);
$i=0;
while($i<$num_rows) {
$title=mysql_result($result,$i,'news_title');
$time=mysql_result($result,$i,'time');
$article=mysql_result($result,$i,'news_text');

echo "$title";
echo nl2br("$article");
$i=$i+1;
}
mysql_close( $dbconnection );
?>[/quote]

try that and give paste the error it gives abck it will say where the problem in the SQL syntax is, i can't see anything wrong from here..
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 IEMC

IEMC
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationMichigan (USA)

Posted 24 March 2006 - 11:48 PM

Thats.... crazy...

Putting that in made it echo the news.. lol thanks :P

#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 24 March 2006 - 11:52 PM

what the... i didnt change the query just added or die(mysql_error());


:S
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users