Resource id #12?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Resource id #12?

Post by JAB Creations »

What is "Resource id #12"?

...and by chance does any one know how I can get this to work without having to include the mysql connection file? I tried passing the $db to the function though that didn't work. Anyway I searched online and couldn't find anything about Resource id #12. It's supposed to be an array of information from MySQL...
Array([tag_name] => application/xhtml+xml), Array([tag_name] => XML), Array([tag_name] => XHTML), Array([tag_name] => CSS)
Not sure what I'm doing wrong here? Here's my code...

Code: Select all

//$mysql_tags = 'SELECT tag_name FROM xhref_tags LEFT JOIN tags ON xhref_tag_id = tag_id WHERE xhref_thread_id = \''.$row['thread_id'].'\'';
//database_tags($mysql_tags);
 
function database_tags($mysql_query)
{
 include("_0_header_01_mysql.php");
 //$join2 = "SELECT * FROM xhref_categories INNER JOIN categories ON xhref_categories.category_id=categories.id WHERE xhref_categories.thread_id='".$row1['id']."' ORDER BY categories.name ASC";
 $result = mysql_query($mysql_query, $db);
 //$row = mysql_fetch_array($mysql_result);
 
  $count = mysql_num_rows($result);
  
 $i=0;
 while($i<=$count)
 {
  $record = mysql_fetch_assoc($result);
  print_r($record);
  if (!empty($result['tag_name'])) {echo '<a href="index.php?tag='.strtolower(str_replace(" ", "_", htmlspecialchars($result['tag_name']))).'">'.htmlspecialchars($result['tag_name']).'</a>';}
  $i++;
  if ($i < $count) {echo ', ';}
 }
}
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Resource id #12?

Post by Christopher »

Connections variables usually contain a "resource id" which is just a number that PHP uses internally to identify the connection. It is just a unique internal number. Obviously PHP does not want to pass around some huge data structure that you could mess up. Just pass $db to the function and it should work fine.
(#10850)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Resource id #12?

Post by requinix »

When your code says $result[tag_name] it should be $record[tag_name]. Got your variables mixed up.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Resource id #12?

Post by JAB Creations »

Ah-ha! Thanks guys...I'm usually sharp in the late evening but I'm physically sick and have been leaving at 6:30am for my new job. I miss the late nights.
Post Reply