Page 1 of 1

Resource id #12?

Posted: Mon Nov 03, 2008 9:27 pm
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 ', ';}
 }
}

Re: Resource id #12?

Posted: Mon Nov 03, 2008 9:34 pm
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.

Re: Resource id #12?

Posted: Mon Nov 03, 2008 9:43 pm
by requinix
When your code says $result[tag_name] it should be $record[tag_name]. Got your variables mixed up.

Re: Resource id #12?

Posted: Mon Nov 03, 2008 9:53 pm
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.