Results 1 to 4 of 4

Thread: Simple news script

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resolved Simple news script

    PHP Code:
    $host="localhost";
    $user="me";
    $password="you";
    $database="hello";


          
    $connection mysql_connect($host,$user,$password)or die ("Error Conecting To DB");
          
    $db mysql_selectdb($database,$connection) or die ("bad table\db data");

          
    $query "SELECT * FROM tblnews";
          
    $result mysql_query($query);

          
    $nrows mysql_num_rows($result);
          
          for (
    $i=0;$i<$nrows;$i++)
          {
            
    $row mysql_fetch_array($result);
            echo 
    $row;
          }
          

    ?> 
    and the error i am getting is
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in path/index.php on line 15
    Any ideas on how to fix this?

    also if i just wanted to select 3 coloums from the db how would i put my query


    $query = "SELECT one two three FROM tblnews"; would that be right?
    Last edited by Pino; Feb 4th, 2005 at 10:50 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width