Warning: Invalid argument supplied for foreach() in***holder.php on line 108

rana99

New Member
Messages
6
Reaction score
0
Points
0
Warning: Invalid argument supplied for foreach() in***holder.php on line 108
Here is the complete code.
  1. <LI class=codeLI><?php <LI class=codeLI> <LI class=codeLI>// ****: holder.php - v. 5.03 <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> // PRELIMINARIES: <LI class=codeLI> <LI class=codeLI> // Get Includes: <LI class=codeLI> <LI class=codeLI> // Determine mode: <LI class=codeLI> $testmode=FALSE; <LI class=codeLI> if (substr(strtolower($_GET['test']),0,1)=='y') $testmode=TRUE; <LI class=codeLI> <LI class=codeLI> // Determine locale: <LI class=codeLI> $in=strtolower($_GET['in']); <LI class=codeLI> if ($in!='us' && $in!='uk' && $in!='ca' && $in!='de' && $in!='fr' && $in!='jp') $in=NULL; // will assign in freebie.php <LI class=codeLI> if (get_magic_quotes_gpc()==FALSE) {$ltr=urldecode($_GET['ltr']);} else {$ltr=$_GET['ltr'];} <LI class=codeLI> if (ctype_alpha($ltr)===FALSE) $ltr='@'; // prevent faked direct-URL hijinks <LI class=codeLI> $ltr=strtoupper(substr($ltr,0,1)); // allow multi-character input data <LI class=codeLI> $showltr='the letter '.$ltr; <LI class=codeLI> if ($ltr==='@') $showltr='a Numeral or Other Non-Alphabetic Character'; <LI class=codeLI> <LI class=codeLI> // Call includes: <LI class=codeLI> // (order here is crucial!) <LI class=codeLI> include('timer.php'); // could replace page with overuse message <LI class=codeLI> require('freebie.php'); <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> // Set Letter-File Spec: <LI class=codeLI> $dropinfile=$bookpagespath.'dropins-'.$ltr.$dot.$in; <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> // Send headers: <LI class=codeLI> // (must be done HERE!) <LI class=codeLI> expiry($dropinfile); <LI class=codeLI> headout(); // language & character-set <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> // PAGE: <LI class=codeLI> <LI class=codeLI> // Send Pagetop: <LI class=codeLI> echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.$crlf; <LI class=codeLI> echo '<html>'.$crlf; <LI class=codeLI> echo '<head>'.$crlf; <LI class=codeLI> echo ' <title>New Books About '.$oneq.$keytext.$oneq.' from ***'.$national.', Title Begins With '.$showltr.'</title>'.$crlf; <LI class=codeLI> echo ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'.$crlf; <LI class=codeLI> echo ' <meta name="description" content="Books about '.$oneq.$keytext.$oneq.' available new from ***'.$national.' whose titles begin with '.$showltr.'." />'.$crlf; <LI class=codeLI> echo ' <meta name="keywords" content="'.$keytext2.', books, bookshop, book shop, bookstore, book store" />'.$crlf; <LI class=codeLI> echo ' <meta name="robots" content="noodp">'.$crlf; <LI class=codeLI> echo $iconline.$crlf; <LI class=codeLI> echo ' <script language="JavaScript" type="text/JavaScript">if (parent.frames.length > 0) top.location.replace(document.location);</script>'.$crlf; <LI class=codeLI> echo '</head>'.$crlf; <LI class=codeLI> echo '<body text="#000000" link="#cc0000" vlink="#6666ff" bgcolor="#'.$border.'" style="font-family:'.$pagefontfamily.'">'.$crlf; <LI class=codeLI> echo $crlf; <LI class=codeLI> echo '<h1 align="center"><font color="#'.$headlinetext.'"><big>"'.$keytext2.'" Books Available New: Titles Beginning With '.$showltr.'</big></font></h1>'.$crlf; <LI class=codeLI> echo $crlf; <LI class=codeLI> echo '<table width="98%" align="center" cellspacing="0" cellpadding="20" border="'.(2+$blockborder).'" rules="none" frame="box" bgcolor="#'.$mainbkground.'">'.$crlf; // border -> rules <LI class=codeLI> // (last-updated row) <LI class=codeLI> if (is_file($dropinfile)!==FALSE) <LI class=codeLI> { <LI class=codeLI> echo ' <tr>'.$crlf; <LI class=codeLI> echo ' <td align="right">'.$crlf; <LI class=codeLI> echo ' <font size="-2" color="#666666">'.$crlf; <LI class=codeLI> echo ' List last updated '.gmdate('D, d M Y H:i:s \G\M\T',filemtime($dropinfile)); <LI class=codeLI> echo ' </font>'.$crlf; <LI class=codeLI> echo ' </td>'.$crlf; <LI class=codeLI> echo ' </tr>'.$crlf; <LI class=codeLI> } <LI class=codeLI> echo ' <tr>'.$crlf; <LI class=codeLI> echo ' <td>'.$crlf; <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> // Process Template: <LI class=codeLI> $html=bringme('hold.htm'); <LI class=codeLI> <LI class=codeLI> // Fix file on the fly: <LI class=codeLI> foreach ($html as $line) <LI class=codeLI> { <LI class=codeLI> $line=trim($line); <LI class=codeLI> // (page-specific data) <LI class=codeLI> $line=str_replace('@@@',$keytext,$line); <LI class=codeLI> $line=str_replace('~~~',$keytext2,$line); <LI class=codeLI> $line=str_replace('^^^',$showltr,$line); <LI class=codeLI> // (***) <LI class=codeLI> $line=str_replace('***.com','*** '.$national,$line); <LI class=codeLI> // (package directory) <LI class=codeLI> $line=str_replace('***',$freeburl,$line); <LI class=codeLI> // (call to self) <LI class=codeLI> $line=str_replace('HOLDERPHP',$freeburl.'holder.php?in='.$in.'&amp;ltr',$line); <LI class=codeLI> // (favicon) <LI class=codeLI> if (strpos($line,'FAVICONLINK')!==FALSE) $line=$iconline; <LI class=codeLI> // (Google AdSense) <LI class=codeLI> if (strpos($line,'ADSENSEDROPIN')!==FALSE) <LI class=codeLI> { <LI class=codeLI> $start=1+strpos($line,'#'); <LI class=codeLI> $cut=strpos($line,$blank,$start); <LI class=codeLI> $refnum=substr($line,$start,$cut-$start); <LI class=codeLI> $adsense=bringme('adsense'.$refnum.'.php'); <LI class=codeLI> foreach ($adsense as $codeline) <LI class=codeLI> {echo $codeline;} <LI class=codeLI> $line=NULL; <LI class=codeLI> } <LI class=codeLI> // (titles-list table data) <LI class=codeLI> if (strpos($line,'PUTDROPINHERE')!==FALSE) <LI class=codeLI> { <LI class=codeLI> $titles=bringme($dropinfile); <LI class=codeLI> foreach ($titles as $title) <LI class=codeLI> {echo $title;} <LI class=codeLI> $line=NULL; <LI class=codeLI> } <LI class=codeLI> echo $line.$crlf; <LI class=codeLI> } // all .htm file lines <LI class=codeLI> <LI class=codeLI> <LI class=codeLI> // Send Pagebottom: <LI class=codeLI> echo ' <br/>'.$crlf; <LI class=codeLI> echo ' </td>'.$crlf; <LI class=codeLI> echo ' </tr>'.$crlf; <LI class=codeLI> echo '</table>'.$crlf; <LI class=codeLI> echo $crlf; <LI class=codeLI> echo '<p align="center"><a href="'.$freeburl.'book-search.php?in='.$in.'">Search *** for <em>any</em> new book.</a></p>'.$crlf; <LI class=codeLI> echo '<p align="center"><a href="'.$freeburl.$myshop.'?in='.$in.'">Return to this book shop\'s "front door" page.</a></p>'.$crlf; <LI class=codeLI> echo '<hr />'.$crlf; <LI class=codeLI> echo $crlf; <LI class=codeLI> spill(bringme('rollyourown.php')); <LI class=codeLI> echo $crlf; <LI class=codeLI> @include('runcoopads.php'); <LI class=codeLI> echo $crlf; <LI class=codeLI> echo '<br/>'.$crlf; <LI class=codeLI> spill(bringme('ganalytics.php')); <LI class=codeLI> echo '</body>'.$crlf; <LI class=codeLI> echo '</html>'.$crlf;
?>













sidecolumn.gif
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Please don't throw all your code up (read that link; it's very important) in a post, especially without formatting it. It's completely unreadable. Create a minimal test case, indent it properly, and use
PHP:
, [html] or [code] tags (as appropriate) to delineate and format the code, and indicate which line is referred to in the error. As it is, we have no way of telling which line is line 108.

An "Invalid argument supplied for foreach" means you've using something that isn't [URL="http://php.net/Traversable"]traversable[/URL] in a [FONT="Courier New"]foreach[/FONT]–what you think is an array or [FONT="Courier New"]PDO[/FONT] result isn't.
 
Last edited:
Top