Re: Query String



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 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;
}
}
?>

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
==================
.



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. ... Maybe try reading the manual? ...
    (comp.lang.php)
  • Re: Query String
    ... for the trees. ... The database connection is OK. ... Maybe try reading the manual? ...
    (comp.lang.php)
  • Re: Single database transaction across a multiple HTTP requests?
    ... database connection that will allow a single transaction across ... The user begins a Cookie session. ... opened and a transaction is begun. ... PHP database connections implicitly ...
    (comp.lang.php)
  • Multiple modules with database access + general app design?
    ... I'm an experience PHP programmer who's been writing python for a couple of ... but in Python I'm having trouble keeping the the database in scope. ... the module to bring the database connection in from its parent. ...
    (comp.lang.python)
  • Re: not able to find the mysqli.dll
    ... // defines database connection data ... // the SQL query to execute ... you might have hitted incompatible versions of PHP ...
    (comp.lang.php)