Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001011

[PHP-DB] Even weirder! From: Lynn Siprelle (lynn <email protected>)
Date: 01/08/01

OK, fooling around, I came up with the following (after routines to connect with the db etc):

$myquery="SELECT name FROM forums";
if(!$result = mysql_db_query("tnh", $myquery)); {
   print("Error performing statement ");
   printf("error: %d %s", mysql_errno($link), mysql_error($link));
}

while($row=mysql_fetch_object($result)) {
   $nextquery = "SELECT id, datestamp, thread, subject, author FROM $row->name ORDER BY datestamp ASC LIMIT 0, 20";

   $sSQL = mysql_fetch_array($nextquery); //this is line 30 in the script
   if (!$s_row = mysql_fetch_object($sSQL)) { //...which makes this 31 :)
      print ("<b>In <a href=\"/phorum/list.php?f=$id\">$row->name</a></b>:</br>\n");
      print ("<font size=-1>Nothing new today.</font><br>\n");
   } else {
      print ("<b>In <a href=\"/phorum/list.php?f=$id\">$row->name</a></b>:</br>\n");
      while($s_row = mysql_fetch_object($sSQL)) {
         print ("<font size=-1>" . date_format($s_row->datestamp, '%b %e, %Y') . ": <a href=\"/phorum/read.php?f=$id&t=$s_row->thread&i=$s_row->id#i$s_row->id\">$s_row->subject</a>--$s_row->author</font><br>\n");
      }
   }
}

This produces weird results, as I'm sure you might imagine:

Error performing statement error: 0
Warning: Supplied argument is not a valid MySQL result resource in /usr/home/sip1/www/htdocs/tnh/phorum/new.php on line 30

Warning: Supplied argument is not a valid MySQL result resource in /usr/home/sip1/www/htdocs/tnh/phorum/new.php on line 31
In Clean and Organized:
Nothing new today.

Warning: Supplied argument is not a valid MySQL result resource in /usr/home/sip1/www/htdocs/tnh/phorum/new.php on line 30

Warning: Supplied argument is not a valid MySQL result resource in /usr/home/sip1/www/htdocs/tnh/phorum/new.php on line 31
In Crafts and Decorating:
Nothing new today.

Warning: Supplied argument is not a valid MySQL result resource in /usr/home/sip1/www/htdocs/tnh/phorum/new.php on line 30

Warning: Supplied argument is not a valid MySQL result resource in /usr/home/sip1/www/htdocs/tnh/phorum/new.php on line 31
In Family:
Nothing new today.

SO. Even though I'm getting an error result, the names ARE getting put into $result, otherwise the "no new messages" routine wouldn't generate, no? Am I having trouble, she asks naively, because this is written into an include file rather than into the page itself, which has its own connection to the same db?

If you weren't all scattered around the globe I'd bake you all brownies.

Thanks,
Lynn

-- 
Lynn Siprelle, Siprelle & Associates: Web Construction and Publishing 
Chief Assoc. Josephine b. 9/9/97 * New Assoc. Louisa due 5/1/01
Business: lynn <email protected> com | Personal: lynsa <email protected>
The New Homemaker: http://www.newhomemaker.com/

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>