Re: Query String
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Sun, 28 Dec 2008 17:36:38 -0500
ajtrichards@xxxxxxxxxxxxxx wrote:
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 woodhttp://us3.php.net/manual/en/function.mysql-fetch-object.php
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
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;
}
}
?>
Which does something entirely different.
What he wants is mysql_fetch_object(), as Scotty indicated. It returns an object, not an array.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: Query String
- From: ajtdds
- Re: Query String
- References:
- Query String
- From: ajtdds
- Re: Query String
- From: FutureShock
- Re: Query String
- From: ajtrichards@xxxxxxxxxxxxxx
- Query String
- Prev by Date: Re: sprintf versus straight entry
- Next by Date: Re: mysqli error?
- Previous by thread: Re: Query String
- Next by thread: Re: Query String
- Index(es):
Relevant Pages
|