Re: Query String



On Dec 28, 7:17 pm, FutureShock <futuresho...@xxxxxxx> wrote:
ajt...@xxxxxxx wrote:
OK I have done this several times before, but now cannot see the wood
for the trees.

I want to search the database table "news" for all items with the
field "active" set to "Yes", and then output the field "title" for
each returned result. The database connection is OK.

I get an error message Fatal error: Call to undefined function
mysql_fetch_objects()

What am I doing wrong... Its been a long day, sorry..

<?php
$query = ("SELECT title FROM news WHERE active='Yes' ");
$result = mysql_query($query) or die ('Error in query: $query . ' .
mysql_error());
if (mysql_num_rows($result) > 0)
   {
   while($row = mysql_fetch_objects($result))
           {
           $title = $row['title']; echo $title;
           }
   }
?>

Thanks in advance.....

Alec

http://us3.php.net/manual/en/function.mysql-fetch-object.php

It is mysql_fetch_object()

Maybe try reading the manual?

Scotty

Use mysql_fetch_array:

<?php
$query = ("SELECT title FROM news WHERE active='Yes' ");
$result = mysql_query($query) or die ('Error in query: $query .
' .mysql_error());

if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$title = $row['title']; echo $title;
}
}
?>
.



Relevant Pages

  • Re: Query String
    ... for the trees. ... I want to search the database table "news" for all items with the ... The database connection is OK. ...
    (comp.lang.php)
  • Re: Query String
    ... for the trees. ... I want to search the database table "news" for all items with the ... The database connection is OK. ... Maybe try reading the manual? ...
    (comp.lang.php)
  • Re: He untracted the greenbroke horse
    ... reading AtPH took perseverance. ... And trees and rocks ...
    (alt.usage.english)
  • OT: The reporters have gotten into the bourbon at the Times-Picayune
    ... I've been reading nola.com for the last few days and I couldn't help but be ... Trees take a big hit in St. Tammany ... To whatever extent life gets back to normal in western St. Tammany Parish, ... AFL Dave's Mom's Thanksgiving Pie Thanksgiving-Pie-Guessing Grand Champion ...
    (alt.fan.letterman)
  • Family Trees on Line
    ... I have been reading all the post regarding sharing of trees on line. ... Support JewishGen with a contribution to the JewishGen General Fund! ...
    (soc.genealogy.jewish)