Jump to content

Not reporting data


IEMC

Recommended Posts

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:
[code]<?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 );
        ?>[/code]

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?
Link to comment
Share on other sites

[!--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..
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.