eosinophil Posted August 24, 2009 Share Posted August 24, 2009 Hello. I'm new to this forum, so maybe the admins will forgive me if I do anything wrong. My problem is this : I have a working piece of code, with no session! But when I try to add this session_start() function I get errors like Warning: Invalid argument supplied for foreach() in I:\raul\list.php on line 137 Warning: Invalid argument supplied for foreach() in I:\raul\list.php on line 163 Fatal error: Cannot use string offset as an array in I:\raul\list.php on line 173 This works when I comment the line session_start(); I know that it should be at the beginning of the file with no extra chars in front of and etc. Anyways the function session_start() does not throw any errors or warnings. The problem is in list.php which does not even have the session_start() in it!! So what the heck does this function do exactly? Thank you ! :'( Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/ Share on other sites More sharing options...
obay Posted August 24, 2009 Share Posted August 24, 2009 Post your code, especially the ones generating the errors. Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-904930 Share on other sites More sharing options...
eosinophil Posted August 24, 2009 Author Share Posted August 24, 2009 list.php <? //session_start(); if(!isset($masterv)){ $inc = "list"; include "index.php"; return; } ?> <div class="center_indent"> <!--content_center--> <!-- bof breadcrumb --> <!-- eof breadcrumb --> <!-- bof upload alerts --> <!-- eof upload alerts --> <div class="centerColumn" id="indexDefault"> <!-- deprecated - to use uncomment this section <div id="" class="content">This is the main define statement for the page for english when no template defined file exists. It is located in: <strong>/includes/languages/english/index.php</strong></div> --> <!-- deprecated - to use uncomment this section <div id="" class="content">Define your main Index page copy here.</div> --> <div id="indexDefaultMainContent" class="content"><div class="left-top-welcome"> <div class="right-top-welcome"> <div class="left-bot-welcome"> <div class="right-bot-welcome"> <div class="inside-welcome"> <? if ($cat) { $link=$cat['descriere'] ."/"; ?> <p><a href="<?=$cat['descriere']?>/" title="<?=$cat['denumire']?>"><strong style="color:#B53F0C; font-weight:bold; font-size:14px; text-decoration:underline; line-height:17px;"><?=strtoupper($cat['denumire'])?> (<?=$cat['total']?>)</strong></a></p> <? if ( ($parinti[$cat['cod']]['1']=='2') && $categorii[$parinti[$cat['cod']]['1']][$parinti[$cat['cod']]['0']]) { ?> <strong>ALTE TIPURI <? foreach ($categorii[0][0] as $v) {?> <? //echo $v['denumire']."<br>" ?> <? if ( ($v['cod'] == $cat['cod']) || ($v['cod'] == $cat['cod_categorie']) || (isset($parinti[$cat['cod_categorie']]['0']) && ($parinti[$cat['cod_categorie']]['0'] == $v['cod'])) ) ?> <? foreach($categorii[1][$v['cod']] as $x) {?> <? //echo $x['denumire']."<br>"?> <? if($parinti[$cat['cod']]['0']==$x['cod'] || $cat['cod']==$x['cod']) { ?> de <a href="<?=$x['descriere']?>" title="<?=$x['denumire']?>"><?=strtoupper($x['denumire'])?></a> <? } ?> <? } } ?> :</strong><br /> <? foreach ($categorii[$parinti[$cat['cod']]['1']][$parinti[$cat['cod']]['0']] as $v){?> <a class="<?=$cat['descriere']==$v['descriere']?"subcatsel":"subcat"?>" href="<?=$v['descriere']?>"><?=$v['denumire']?></a> <? } ?> <br /> <? } // daca nu exista vitr magazinului afisez si filtrele // daca exista insmn ca ii afisez numai subcategoriile si mai jos ii arat vitrin acestei categori if (!$cat['vitrina']) { ?> <? //daca are producatori if ($cat['producs']) { ?> <strong>PRODUCATORI :</strong><br /> <? if ($url['producator']) { $alink = $link; if ($url['detalii']){ $alink .= "filtre/"; foreach ($url['detalii'] as $k=>$v) $alink .=$k."=".$v."~"; } ?> <a href="<?=$alink?>" class="filtrudes">X</a> <? } ?> <? foreach ($cat['producs'] as $producator) if ($producator){ $alink = $link . strtourl($producator)."/"; if ($url['detalii']) { $alink .= "filtre/"; foreach ($url['detalii'] as $k=>$v) $alink .= $k."=".$v."~"; } ?> <a href="<?=$alink?>" <?=$url['producator']['descriere']==strtourl($producator)?'class="filtrusel"':'class="filtru"'?> > <?=$producator?></a> <? } ?> <br /> <? } if ($url['producator']) $link .= $url['producator']['descriere']."/"; if ($cat['filts']) { //print_r($cat['filts']); $link .= "filtre/"; ?> <? foreach ($cat['filts'] as $filtru) { $alink = $link; if ($url['detalii']){ foreach ($url['detalii'] as $k=>$v) if ($k!=$filtru['titlu']) $alink .= $k."=".$v."~"; } ?> <strong><?=$filtru['titlu']?> :</strong><br /> <? if ($url['detalii']&&isset($url['detalii'][$filtru['titlu']])) {?> <a href="<?=$alink?>" class="filtrudes">X</a> <? } ?> <? $f_valori = explode('^',$filtru['valori']); foreach ($f_valori as $valoare) { $valoare = trim($valoare); $blink = $alink.$filtru['titlu']."=".$valoare; ?> <a href="<?=$blink?>" <?=$url['detalii']&&isset($url['detalii'][$filtru['titlu']])&&$url['detalii'][$filtru['titlu']]==$valoare?'class="filtrusel"':'class="filtru"'?> title="<?=$filtru['titlu']?> = <?=$valoare?>" ><?=$valoare?> <?=$filtru['um']?></a> <? } ?> <br /> <? } ?> <? } if ($cat['total']) { ?> <strong>ORDONARE DUPA: </strong><br /> <? //echo $link; $alink = $link; if ($url['detalii']){ foreach ($url['detalii'] as $k => $v) $alink .= $k."=".$v."~"; if(substr($alink,-1)=='~') $alink = substr($alink,0,-1); $alink .= "/"; } ?> <a <?=$url['sort']=='pret-asc'?'class="filtrusel"':'class="filtru"'?> href="<?=$alink?>pret-asc/">pret crescator</a> <a <?=$url['sort']=='pret-desc'?'class="filtrusel"':'class="filtru"'?> class="filtru" href="<?=$alink?>pret-desc/">pret descrescator</a> <a <?=$url['sort']=='vandute'?'class="filtrusel"':'class="filtru"'?> class="filtru" href="<?=$alink?>vandute/">cele mai vandute</a> <? $nrpag = ceil($cat['total']/10); if ($nrpag>1) { ?> <br /> <strong>PAGINA: </strong><br /> <? $alink = $link; if ($url['detalii']){ foreach ($url['detalii'] as $k => $v) $alink .= $k."=".$v."~"; if(substr($alink,-1)=='~') $alink = substr($alink,0,-1); $alink .= "/"; } $alink .= $url['sort']; $puncte = ""; for ($i=1; $i<=$nrpag; $i++){ if (($nrpag>6 && ($i==1 || $i==2 || $i==3 || $i==($nrpag-1) || $i==$nrpag)) || $nrpag<=6){ ?> <a <?=$url['pag']==$i?'class="filtrusel"':'class="filtru"'?> href="<?=$alink?>/<?=$i?>/">- <?=$i?> -</a> <? } else if (!$puncte){ echo " ... "; $puncte = "ok"; } } ?> <? } ?> <? } } //iful de la vitrina magazinului if ($cat['subcats']) { ?> <strong>SUBCATEGORII :</strong><br /> <? foreach ($cat['subcats'] as $subcategorie) { ?> <a href="<?=$subcategorie['descriere']?>" class="subcat"><?=$subcategorie['denumire']?></a> <? } ?> <? } } ?> </div> </div> </div> </div> </div></div> <div class="centerBoxWrapper" id="featuredProducts"> <!-- bof: list products --> <? if ($cat && $cat['prods']) foreach ($cat['prods'] as $produs){ ?> <div class="centerBoxContentsFeatured centeredContent back" style="width:100%;"><div class="product_list"> <div class="left" style="width:191px;"><a href="<?=$cat['descriere']?>/<?=$produs['seo']?>_p<?=$produs['cod']?>.html"><img src="<?=$calepoze?><?=strtourl($produs['denumire'])?>_mica.jpg" alt="<?=$produs['denumire']?>" title="<?=$produs['denumire']?>" style="margin-left:35px; margin-top:20px; padding:2px; border:dotted 1px #f2f2f2" /></a></div> <div class="right" style="margin-left:-191px;"> <div style="margin-left:191px;"> <div class="name"><a href="<?=$cat['descriere']?>/<?=$produs['seo']?>_p<?=$produs['cod']?>.html"><?=$produs['denumire']?></a></div> <div class="text"> <div class="side-left-desc"> <div class="side-right-desc"> <div class="side-top-desc"> <div class="side-bot-desc"> <div class="left-top-desc"> <div class="right-top-desc"> <div class="left-bot-desc"> <div class="right-bot-desc"> <div class="inside-desc"> <? if($produs['specificatii']) for ($i=0; $i<min(count($produs['specificatii']),4);$i++){ $det = $produs['specificatii'][$i]; if ($det['valoare']) {?> <strong><?=$det['titlu']?> : </strong> <?=$det['valoare']?> <?=$det['um']?><br /> <? } } ?> <? if($produs['producator']) { $alink = $cat['descriere'] ."/"; $blink =''; if ($url['detalii']){ $blink .= "filtre/"; foreach ($url['detalii'] as $k=>$v) $blink .= $k ."=".$v."~"; } ?> <strong>PRODUCATOR : </strong> <a title="<?=$cat['denumire']?> | <?=$produs['producator']?>" href="<?=$alink?><?=strtourl($produs['producator'])?>/<?=$blink?>"><?=$produs['producator']?></a><br /> <? } ?> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <div class="price"><strong><?=$produs['pret']?> ron </strong></div> <div class="button"><a href="<?=$cat['descriere']?>/<?=$produs['seo']?>_p<?=$produs['cod']?>.html"><img src="img/button_goto_prod_details.gif" alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="49" height="19" /></a></div><br class="clear" /> </div> </div> <div class="clear"></div> </div></div> <br class="clearBoth" /> <!-- eof: list products --> <? } else if ($cat && $cat['vitrina']) include "list-vitrina.php"; ?> </div> </div> <!-- bof BANNERS GROUPSET 4 --> <!-- eof BANNERS GROUPSET 4 --> <div class="clear"></div> <!--eof content_center--> </div> Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-904931 Share on other sites More sharing options...
obay Posted August 24, 2009 Share Posted August 24, 2009 whoa, use the code tag, man! Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-904933 Share on other sites More sharing options...
eosinophil Posted August 24, 2009 Author Share Posted August 24, 2009 sorry !! list.php <? //session_start(); if(!isset($masterv)){ $inc = "list"; include "index.php"; return; } ?> <div class="center_indent"> <!--content_center--> <!-- bof breadcrumb --> <!-- eof breadcrumb --> <!-- bof upload alerts --> <!-- eof upload alerts --> <div class="centerColumn" id="indexDefault"> <!-- deprecated - to use uncomment this section <div id="" class="content">This is the main define statement for the page for english when no template defined file exists. It is located in: <strong>/includes/languages/english/index.php</strong></div> --> <!-- deprecated - to use uncomment this section <div id="" class="content">Define your main Index page copy here.</div> --> <div id="indexDefaultMainContent" class="content"><div class="left-top-welcome"> <div class="right-top-welcome"> <div class="left-bot-welcome"> <div class="right-bot-welcome"> <div class="inside-welcome"> <? if ($cat) { $link=$cat['descriere'] ."/"; ?> <p><a href="<?=$cat['descriere']?>/" title="<?=$cat['denumire']?>"><strong style="color:#B53F0C; font-weight:bold; font-size:14px; text-decoration:underline; line-height:17px;"><?=strtoupper($cat['denumire'])?> (<?=$cat['total']?>)</strong></a></p> <? if ( ($parinti[$cat['cod']]['1']=='2') && $categorii[$parinti[$cat['cod']]['1']][$parinti[$cat['cod']]['0']]) { ?> <strong>ALTE TIPURI <? foreach ($categorii[0][0] as $v) {?> <? //echo $v['denumire']."<br>" ?> <? if ( ($v['cod'] == $cat['cod']) || ($v['cod'] == $cat['cod_categorie']) || (isset($parinti[$cat['cod_categorie']]['0']) && ($parinti[$cat['cod_categorie']]['0'] == $v['cod'])) ) ?> <? foreach($categorii[1][$v['cod']] as $x) {?> <? //echo $x['denumire']."<br>"?> <? if($parinti[$cat['cod']]['0']==$x['cod'] || $cat['cod']==$x['cod']) { ?> de <a href="<?=$x['descriere']?>" title="<?=$x['denumire']?>"><?=strtoupper($x['denumire'])?></a> <? } ?> <? } } ?> :</strong><br /> <? foreach ($categorii[$parinti[$cat['cod']]['1']][$parinti[$cat['cod']]['0']] as $v){?> <a class="<?=$cat['descriere']==$v['descriere']?"subcatsel":"subcat"?>" href="<?=$v['descriere']?>"><?=$v['denumire']?></a> <? } ?> <br /> <? } // daca nu exista vitr magazinului afisez si filtrele // daca exista insmn ca ii afisez numai subcategoriile si mai jos ii arat vitrin acestei categori if (!$cat['vitrina']) { ?> <? //daca are producatori if ($cat['producs']) { ?> <strong>PRODUCATORI :</strong><br /> <? if ($url['producator']) { $alink = $link; if ($url['detalii']){ $alink .= "filtre/"; foreach ($url['detalii'] as $k=>$v) $alink .=$k."=".$v."~"; } ?> <a href="<?=$alink?>" class="filtrudes">X</a> <? } ?> <? foreach ($cat['producs'] as $producator) if ($producator){ $alink = $link . strtourl($producator)."/"; if ($url['detalii']) { $alink .= "filtre/"; foreach ($url['detalii'] as $k=>$v) $alink .= $k."=".$v."~"; } ?> <a href="<?=$alink?>" <?=$url['producator']['descriere']==strtourl($producator)?'class="filtrusel"':'class="filtru"'?> > <?=$producator?></a> <? } ?> <br /> <? } if ($url['producator']) $link .= $url['producator']['descriere']."/"; if ($cat['filts']) { //print_r($cat['filts']); $link .= "filtre/"; ?> <? foreach ($cat['filts'] as $filtru) { $alink = $link; if ($url['detalii']){ foreach ($url['detalii'] as $k=>$v) if ($k!=$filtru['titlu']) $alink .= $k."=".$v."~"; } ?> <strong><?=$filtru['titlu']?> :</strong><br /> <? if ($url['detalii']&&isset($url['detalii'][$filtru['titlu']])) {?> <a href="<?=$alink?>" class="filtrudes">X</a> <? } ?> <? $f_valori = explode('^',$filtru['valori']); foreach ($f_valori as $valoare) { $valoare = trim($valoare); $blink = $alink.$filtru['titlu']."=".$valoare; ?> <a href="<?=$blink?>" <?=$url['detalii']&&isset($url['detalii'][$filtru['titlu']])&&$url['detalii'][$filtru['titlu']]==$valoare?'class="filtrusel"':'class="filtru"'?> title="<?=$filtru['titlu']?> = <?=$valoare?>" ><?=$valoare?> <?=$filtru['um']?></a> <? } ?> <br /> <? } ?> <? } if ($cat['total']) { ?> <strong>ORDONARE DUPA: </strong><br /> <? //echo $link; $alink = $link; if ($url['detalii']){ foreach ($url['detalii'] as $k => $v) $alink .= $k."=".$v."~"; if(substr($alink,-1)=='~') $alink = substr($alink,0,-1); $alink .= "/"; } ?> <a <?=$url['sort']=='pret-asc'?'class="filtrusel"':'class="filtru"'?> href="<?=$alink?>pret-asc/">pret crescator</a> <a <?=$url['sort']=='pret-desc'?'class="filtrusel"':'class="filtru"'?> class="filtru" href="<?=$alink?>pret-desc/">pret descrescator</a> <a <?=$url['sort']=='vandute'?'class="filtrusel"':'class="filtru"'?> class="filtru" href="<?=$alink?>vandute/">cele mai vandute</a> <? $nrpag = ceil($cat['total']/10); if ($nrpag>1) { ?> <br /> <strong>PAGINA: </strong><br /> <? $alink = $link; if ($url['detalii']){ foreach ($url['detalii'] as $k => $v) $alink .= $k."=".$v."~"; if(substr($alink,-1)=='~') $alink = substr($alink,0,-1); $alink .= "/"; } $alink .= $url['sort']; $puncte = ""; for ($i=1; $i<=$nrpag; $i++){ if (($nrpag>6 && ($i==1 || $i==2 || $i==3 || $i==($nrpag-1) || $i==$nrpag)) || $nrpag<=6){ ?> <a <?=$url['pag']==$i?'class="filtrusel"':'class="filtru"'?> href="<?=$alink?>/<?=$i?>/">- <?=$i?> -</a> <? } else if (!$puncte){ echo " ... "; $puncte = "ok"; } } ?> <? } ?> <? } } //iful de la vitrina magazinului if ($cat['subcats']) { ?> <strong>SUBCATEGORII :</strong><br /> <? foreach ($cat['subcats'] as $subcategorie) { ?> <a href="<?=$subcategorie['descriere']?>" class="subcat"><?=$subcategorie['denumire']?></a> <? } ?> <? } } ?> </div> </div> </div> </div> </div></div> <div class="centerBoxWrapper" id="featuredProducts"> <!-- bof: list products --> <? if ($cat && $cat['prods']) foreach ($cat['prods'] as $produs){ ?> <div class="centerBoxContentsFeatured centeredContent back" style="width:100%;"><div class="product_list"> <div class="left" style="width:191px;"><a href="<?=$cat['descriere']?>/<?=$produs['seo']?>_p<?=$produs['cod']?>.html"><img src="<?=$calepoze?><?=strtourl($produs['denumire'])?>_mica.jpg" alt="<?=$produs['denumire']?>" title="<?=$produs['denumire']?>" style="margin-left:35px; margin-top:20px; padding:2px; border:dotted 1px #f2f2f2" /></a></div> <div class="right" style="margin-left:-191px;"> <div style="margin-left:191px;"> <div class="name"><a href="<?=$cat['descriere']?>/<?=$produs['seo']?>_p<?=$produs['cod']?>.html"><?=$produs['denumire']?></a></div> <div class="text"> <div class="side-left-desc"> <div class="side-right-desc"> <div class="side-top-desc"> <div class="side-bot-desc"> <div class="left-top-desc"> <div class="right-top-desc"> <div class="left-bot-desc"> <div class="right-bot-desc"> <div class="inside-desc"> <? if($produs['specificatii']) for ($i=0; $i<min(count($produs['specificatii']),4);$i++){ $det = $produs['specificatii'][$i]; if ($det['valoare']) {?> <strong><?=$det['titlu']?> : </strong> <?=$det['valoare']?> <?=$det['um']?><br /> <? } } ?> <? if($produs['producator']) { $alink = $cat['descriere'] ."/"; $blink =''; if ($url['detalii']){ $blink .= "filtre/"; foreach ($url['detalii'] as $k=>$v) $blink .= $k ."=".$v."~"; } ?> <strong>PRODUCATOR : </strong> <a title="<?=$cat['denumire']?> | <?=$produs['producator']?>" href="<?=$alink?><?=strtourl($produs['producator'])?>/<?=$blink?>"><?=$produs['producator']?></a><br /> <? } ?> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <div class="price"><strong><?=$produs['pret']?> ron </strong></div> <div class="button"><a href="<?=$cat['descriere']?>/<?=$produs['seo']?>_p<?=$produs['cod']?>.html"><img src="img/button_goto_prod_details.gif" alt="Go To This Product's Detailed Information" title=" Go To This Product's Detailed Information " width="49" height="19" /></a></div><br class="clear" /> </div> </div> <div class="clear"></div> </div></div> <br class="clearBoth" /> <!-- eof: list products --> <? } else if ($cat && $cat['vitrina']) include "list-vitrina.php"; ?> </div> </div> <!-- bof BANNERS GROUPSET 4 --> <!-- eof BANNERS GROUPSET 4 --> <div class="clear"></div> <!--eof content_center--> </div> Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-905027 Share on other sites More sharing options...
eosinophil Posted August 24, 2009 Author Share Posted August 24, 2009 so nobody is going to answer me ? or maybe you could solve this one : http://codingforums.com/showthread.php?t=88006 ? any help would be greatly appreciated ! I think the question would be : what the &^%$ does this session_start() _exactly_ do ? why does it work with no session_start()? the code has nothing to do with the session. just with $_REQUEST. I'm so new to php so I have no clue about this stuff. Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-905069 Share on other sites More sharing options...
kenrbnsn Posted August 24, 2009 Share Posted August 24, 2009 Don't be so impatient. The only "session_start()" in the code you posted is commented out, so this is not the code that is giving you the errors. If you're unsure of what it does, read the manual entry for session_start Ken Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-905074 Share on other sites More sharing options...
eosinophil Posted August 24, 2009 Author Share Posted August 24, 2009 ok! I have this file _data.php <?session_start(); //error_reporting(1); error_reporting(6143); ini_set("display_errors", true); foreach ($_REQUEST as $k=>$v) $$k=htmlspecialchars($v); ?> If I comment session_start() it runs ok, but if not the first post's warnings and fatal error appear! Please help !!! Thanks , I read the manual, but I feel something is missing. This function has to be doing something else or this is very strange. Link to comment https://forums.phpfreaks.com/topic/171610-please-helpsession_start-problem/#findComment-905085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.