jacque99 Posted December 25, 2010 Share Posted December 25, 2010 Hello everyone, I have a problem in the session start in my cart I always get the following error: Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition panier of the object you are trying to operate on was loaded _before_ the session was started Here is the script : <?php $date_echeance = date("d-m-Y", strtotime("+ 1 MONTHS")); $d = date("d-m-Y"); echo "<html>"; echo "<head> "; echo "<title>HTML2PDF - Examples - en</title> "; echo "</head>"; echo "</html>"; session_start(); include_once '/../../../panier.class.php'; $contenu = ""; $page = null; /************************************************************************************************* ** affectations variables ** *************************************************************************************************/ $page->maj = isset($_POST["maj_x"]) ? $_POST["maj_x"] : ""; $page->base = ((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER["HTTP_HOST"]; $page->dirname = dirname($_SERVER["SCRIPT_NAME"]); $page->query = isset($_SERVER["QUERY_STRING"]) ? "?".$_SERVER["QUERY_STRING"]."" : ""; $page->protocol = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https" : "http"; $page->action = $page->protocol."://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"].$page->query; $page->panier = isset($_SESSION['panier']) ? unserialize($_SESSION['panier']) : ""; /************************************************************************************************* ** programme principal ** *************************************************************************************************/ print ' <html> <head> <title>Consultation Panier</title> </head> <body> <form name="form1" method="post" action="'.$page->action.'" enctype="application/x-www-form-urlencoded">'; if ($page->maj) maj($page); $contenu .= Affichages($page); print $contenu.' </form> </body> </html>'; $_SESSION["panier"] = serialize($page->panier); /************************************************************************************************* ** fonctions ** *************************************************************************************************/ //Créer les variables de session pour le num du facture et le nom du client $num_fatcure=$_POST['num_fatcure']; $nom_client=$_POST['nom_client']; $observation=$_POST['observation']; echo $observation; //echo $_SESSION['num_fatcure'] ; $_SESSION['num_fatcure'] = $num_fatcure ; $_SESSION['nom_client'] = $nom_client ; $_SESSION['observation'] = $observation ; ?> <form> <table> <tr> <td style="width: 10%; text-align: left;">Observationppp<br /></td> <th style="width: 10%"><textarea id="resize-demo" name="observation22" value="<?php echo $_SESSION['observation']; ?>" style="font-weight:700; "> </textarea> </th> <script type="text/javascript">/*<![CDATA[*/(function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:150,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter('textarea').each(function(){var c=a(this).css({resize:'none','overflow-y':'hidden'}),k=c.height(),f=(function(){var l=['height','width','lineHeight','textDecoration','letterSpacing'],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr('id').removeAttr('name').css({position:'absolute',top:0,left:-9999}).css(h).insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css('overflow-y','');return}b.onResize.call(this);b.animate&&c.css('display')==='block'?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind('.dynSiz').bind('keyup.dynSiz',g).bind('keydown.dynSiz',g).bind('change.dynSiz',g)});return this}})(jQuery);$('textarea#resize-demo').autoResize();/*]]>*/</script> </tr> </table> </form> <?php //************************************************************************************************ // affichage principal function Affichages(&$page) { if ($page->panier == "" || (is_object($page->panier) && $page->panier->getNombreArticle() <= 0)) return '<br /> Votre panier est vide<br /><a href="liste_article.php">Liste Produits</a>'; $d = date("d-m-Y"); $date_echeance = date("d-m-Y", strtotime("+ 1 MONTHS")); $num_fatcure=strtoupper($_POST['num_fatcure']); $nom_client=strtoupper($_POST['nom_client']); $observation=$_POST['observation']; //echo $num_fatcure; //echo $nom_client; ?> <?php $out = ' <table align="center" style="border-radius: 6mm; border: none; background: #DDDDAA; font-size: 7pt;" > <tr> <td style="width: 70mm; font-size: 10pt ; height: 0mm; text-align: center; "> <b>CMELEC</b> <br> </td> </tr> <tr> <td style="width: 70mm; height: 0mm; text-align: center; "> 28 Rue Louis D’Eichthale - 45230 Sainte Geneviève des Bois<br></td> </tr> <tr> <td style="width: 70mm; height: 0mm; text-align: center; "> Tél. : 02/38/92/54/53 - Mobile. : 06/12/70/41/12<br></td> </tr> <tr> <td style="width: 70mm; height: 0mm; text-align: center; "> SIREN : 525 179552<br></td> </tr> </table> <br /> <table cellspacing="0" style="width: 100%; border: solid 0px black; background: #ffffff; text-align: center; "> <tr> <td style="width: 14%; font-size: 8pt ; text-align: left;">Facture n°<br /></td> <th style="width: 14% ; font-size: 8pt ;">'.$num_fatcure.'</th> </tr> <tr> <td style="width: 14%; font-size: 8pt ; text-align: left;">Nom client<br /></td> <th style="width: 14%; font-size: 8pt ;">'.$nom_client.'</th> </tr> <tr> <td style="width: 14%; font-size: 8pt ; text-align: left;">Date facture<br /></td> <th style="width: 14%; font-size: 8pt ;">'.$d.'</th> </tr> <tr> <td style="width: 14%; font-size: 8pt ; text-align: left;">Date déchéance<br /></td> <th style="width: 14%; font-size: 8pt ;">'.$date_echeance.'</th> </tr> </table> <br> <br /> <table cellspacing="0" style="width: 100%; border: solid 1px black; background: #E7E7E7; text-align: center; font-size: 10pt;"> <tr> <td colspan="6"></td> </tr> <tr> <th style="width: 12%">Référence</th> <th style="width: 20%">P.U (H.T)</th> <th style="width: 13%">Quantité</th> <th style="width: 10%">Total H.T</th> <th style="width: 13%">Total T.T.C</th> </tr>'; foreach ($page->panier->article as $numserie => $val) { $out .= ' <tr> <td style="width: 12%;">'.$numserie.'</td> <td style="width: 20%;">'.$page->panier->getPrixArticle($numserie).' €</td> <td style="width: 20%;">'.$page->panier->getQteArticle($numserie).'</td> <td style="width: 10% ">'.$page->panier->getMontantArticle($numserie).' €</td> <td style="width: 13% ">'.$page->panier->getMontantTTCArticle($numserie).' €</td> <td style="width: 5% "><input type="hidden" size="10" name="qte_'.$numserie.'" value="'.$page->panier->getQteArticle($numserie).'" /></td> </tr>'; } $out .= ' <tr> <td colspan="6"><hr width="40%" /></td> </tr> <tr> <td colspan="5" align="right" class="titrecell">Sous-Total HT :</td> <td align="right" class="intitule">'.$page->panier->getTotalHT().' €</td> </tr> <tr> <td colspan="5" align="right" class="titrecell">Total HT :</td> <td align="right" class="intitule">'.$page->panier->getTotalFinalHT().' €</td> </tr> <tr> <td colspan="5" align="right" class="titrecell">TVA ('.$page->panier->getTVA().' %) :</td> <td align="right" class="intitule">'.$page->panier->getTotalFinalTVA().' €</td> </tr> <tr> <td colspan="5" align="right" class="titrecell">Total TTC :</td> <td align="right" class="intitule">'.$page->panier->getTotalFinalTTC().' €</td> </tr> <tr> <td colspan="6"></td> </tr> </table>'; if($observation!=null){ $out .= ' <br /> <table border: solid 1px white; background: #ffffff;> <tr> <td style="width: 5%; solid 1px red; text-align: left;">Observation :</td> </tr> <tr> <th style="width: 5%"><textarea id="resize-demo" name="observation" cols="34" rows="4" style="font-weight:700; "> '.$observation.' </textarea> </th> </tr> </table> '; echo "<br />"; } else { } return $out; } function maj(&$page) { foreach ($_POST as $cle => $valeur) { if (preg_match("/suppr_(.*)/", $cle, $res)) $page->panier->supprimerArticle($res[1]); if (preg_match("/qte_(.*)/", $cle, $res)) $page->panier->miseAJourQteArticle($res[1], $valeur); } if ($page->panier->getNombreArticle() <= 0) { $page->panier->destroy(); $page->panier = null; } } //session_start(); $num_fatcure=$_POST['num_fatcure']; $nom_client=$_POST['nom_client']; echo $num_fatcure; echo $nom_client; ?> <br> </page> Link to comment https://forums.phpfreaks.com/topic/222606-probleme-start-session/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 25, 2010 Share Posted December 25, 2010 Why don't you just do what the error message tells you to do - Please ensure that the class definition panier of the object you are trying to operate on was loaded _before_ the session was started Link to comment https://forums.phpfreaks.com/topic/222606-probleme-start-session/#findComment-1151227 Share on other sites More sharing options...
jacque99 Posted December 25, 2010 Author Share Posted December 25, 2010 I tried on several places but it does not work Link to comment https://forums.phpfreaks.com/topic/222606-probleme-start-session/#findComment-1151228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.