Jump to content

[SOLVED] Warning: Invalid argument supplied for foreach() ?


littlevisuals

Recommended Posts

Hi everyone  :D

 

Trying to add tags to a script so i've found a script online. However every time I run the script I get the error

 

Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/tags.php on line 2

 

Can anybody tell me what this means?

 

Im using PHP Version 5.2.5, MySQL 5.1.35 via socket

Sure, here is the code I have

 

<?php
      foreach ( $articleTags as $tag ) {
   
       
   
          $resultID = @mysql_query("SELECT tag_id FROM articles_tags WHERE tag_name='$tag'") or
   
              outputMessage( "SELECT FROM articles_tags failed: " . @mysql_error($linkID) );
   
          if ( $row = mysql_fetch_array($resultID, MYSQL_ASSOC) ) {
   
       
   
              $tagID = $row['tag_id'];
   
              @mysql_query("UPDATE articles_tags SET num_articles=num_articles+1 WHERE tag_id=$tagID") or
  
                  outputMessage( "UPDATE articles_tags failed: " . @mysql_error($linkID) );
  
       
  
          } else {
  
       
  
            @mysql_query("INSERT INTO articles_tags(tag_name) VALUES ('$tag')") or
  
                  outputMessage( "INSERT INTO articles_tags failed: " . @mysql_error($linkID) );
  
              $tagID = @mysql_insert_id() or outputMessage( "mysql_insert_id() failed: " . @mysql_error($linkID) );
  
          }
  
       
  
          @mysql_query("INSERT INTO articles_tagged (tag_id, article_id) VALUES ($tagID, $articleID)") or
  
              outputMessage( "INSERT INTO articles_tagged failed: " . @mysql_error($linkID) );
  
      }
  ?>

I followed this tutorial online

 

http://www.itnewb.com/v/Comprehensive-Guide-to-PHP-MySQL-Tag-Clouds-Includes-Demo/page4

 

I couldn't understand where $articlestags even fits into it  :confused:

 

Im going to modify it into my cms im making but thought id see if it works first.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.