Re: Query String
- From: "ajtrichards@xxxxxxxxxxxxxx" <ajtrichards@xxxxxxxxxxxxxx>
- Date: Sun, 28 Dec 2008 15:22:11 -0800 (PST)
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;
}
}
?>
.
- Follow-Ups:
- Re: Query String
- From: Jerry Stuckle
- Re: Query String
- References:
- Query String
- From: ajtdds
- Re: Query String
- From: FutureShock
- Query String
- Prev by Date: mysqli error?
- Next by Date: Re: "time" a query
- Previous by thread: Re: Query String
- Next by thread: Re: Query String
- Index(es):
Relevant Pages
|