caseyh Posted March 13, 2007 Share Posted March 13, 2007 ??? I recently edited some files and now they dont work, the thing is i cant figure out why. I look at it and it should work but it doesn't. When ever i include a new class that I just did my site doesnt work at all <?php //////////////////////////////////////////// /////////////////////////////////////////// //* Copy Right Casey Hillman 2007 *// //* None of this code may be used *// //* without prior written consent *// //* from its respected owner! *// ////////////////////////////////////// ///////////////////////////////////// // Class used to output default page class cSession { ///////////////////////////////////////////////////////// /////////// Class cSession's Constructor ///////// /////////////////////////////////////////////////////// // Variable to hold ref to external object var $refToClass=''; // Constructor, passes ref of an external object into cConGen // sets it to $ref local function cSession(&$ref) { $this->refToClass=$ref; } //////////////////////////////////////////////////////// ///////// Class cSession's Default Attributes ///////// ////////////////////////////////////////////////////// // Cart Begins Empty $cart = array(); //////////////////////////////////////////////////////// ///////////// Class cSession's Functions ////////////// ////////////////////////////////////////////////////// function begin() { session_start(); $this->setVar('log',0); $this->setVar('items','0'); $this->setVar('cart',$this->$cart); } function addItem($itemN, $itemQ) { $new = array('$itemN'=>'$itemQ'); $current = $_SESSION['cart']; $add = array_merge($new,$current); $this->setVar('cart',$add); $curr = $this->get_var('items'); $add = $curr + 1; $this->setVar{'items',$add); $comment = "<h3>The Item Has Been Succesfully Added To Your Cart</h3>"; $comment .= "<a href='javascript:init('index.php')'>Continue Shopping</a> |"; $comment .= " <a href='javascript:init('index.php?page=checkout')'>Proceed To Checkout</a>"; $echo "$comment"; } function login($uname,$pswd) { if( !$uname || !$pswd) { return false; } else { $this->setVar('user',$uname); $this->setVar('log','1'); $this->setVar('cart','0'); return true;} } function setVar( $varName, $varVal ) { if( !$varName || !$varVal ) { return false; } $_SESSION[$varName] = $varVal; } function get_var( $var_name ) { return $_SESSION[$var_name]; } function del_var( $var_name ) { unset( $_SESSION[$var_name] ); } function del_vars( $arr ) { if( !is_array( $arr ) ) { return false; } foreach( $arr as $element ) { unset( $_SESSION[$element] ); } return true; } function del_all_vars() { del_all_vars(); } function endSes() { $_SESSION = array(); session_destroy(); } } ?> Any insite into why it kills my site when i just include it would help out a lot. In my index.php i have // Include class cConGen for paging system include ("classes/cConGen.inc.php"); // Include class cDataBase for mySQL databse connectivity include("classes/cDataBase.inc.php"); // Include class cSession for session support include("classes/cSession.inc.php"); // Create object $data of class cDataBase $data = new cDataBase(); // Create object $ses of class cSession $ses = new cSession($data); // Create object $page of class cConGen $page = new cConGen($data); which gives me a blank page, but if i comment out like this // Include class cConGen for paging system include ("classes/cConGen.inc.php"); // Include class cDataBase for mySQL databse connectivity include("classes/cDataBase.inc.php"); // Include class cSession for session support //include("classes/cSession.inc.php"); // Create object $data of class cDataBase $data = new cDataBase(); // Create object $ses of class cSession //$ses = new cSession($data); // Create object $page of class cConGen $page = new cConGen($data); it works fine, if i cant figure it out im just gonna start over. well its crappy code i know, its my first time working with sessions and im just starting simple. Well thanks in advanced for any help. Quote Link to comment Share on other sites More sharing options...
caseyh Posted March 13, 2007 Author Share Posted March 13, 2007 the fourm will not let me edit my post for some reason, but the cSession class should be this <?php //////////////////////////////////////////// /////////////////////////////////////////// //* Copy Right Casey Hillman 2007 *// //* None of this code may be used *// //* without prior written consent *// //* from its respected owner! *// ////////////////////////////////////// ///////////////////////////////////// // Class used to output default page class cSession { ///////////////////////////////////////////////////////// /////////// Class cSession's Constructor ///////// /////////////////////////////////////////////////////// // Variable to hold ref to external object var $refToClass=''; // Constructor, passes ref of an external object into cConGen // sets it to $ref local function cSession(&$ref) { $this->refToClass=$ref; } //////////////////////////////////////////////////////// ///////// Class cSession's Default Attributes ///////// ////////////////////////////////////////////////////// // Cart Begins Empty $cart = array(); //////////////////////////////////////////////////////// ///////////// Class cSession's Functions ////////////// ////////////////////////////////////////////////////// function begin() { session_start(); $this->setVar('log',0); $this->setVar('items','0'); $this->setVar('cart',$this->$cart); } function addItem($itemN, $itemQ) { $new = array('$itemN'=>'$itemQ'); $current = $_SESSION['cart']; $add = array_merge($new,$current); $this->setVar('cart',$add); $curr = $this->get_var('items'); $add = $curr + 1; $this->setVar{'items',$add); $comment = "<h3>The Item Has Been Succesfully Added To Your Cart</h3>"; $comment .= "<a href='javascript:init('index.php')'>Continue Shopping</a> |"; $comment .= " <a href='javascript:init('index.php?page=checkout')'>Proceed To Checkout</a>"; $echo "$comment"; } function login($uname,$pswd) { if( !$uname || !$pswd) { return false; } else { $this->setVar('user',$uname); $this->setVar('log','1'); $this->setVar('cart','0'); return true;} } function setVar( $varName, $varVal ) { if( !$varName || !$varVal ) { return false; } $_SESSION[$varName] = $varVal; } function get_var( $var_name ) { return $_SESSION[$var_name]; } function del_var( $var_name ) { unset( $_SESSION[$var_name] ); } function del_vars( $arr ) { if( !is_array( $arr ) ) { return false; } foreach( $arr as $element ) { unset( $_SESSION[$element] ); } return true; } function del_all_vars() { del_all_vars(); } function endSes() { $_SESSION = array(); session_destroy(); } } ?> I have noticed already quite a few people have viewed this topic, im wondering if yall can't see anything wrong or if its just code so crappy to not even bother? Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted March 13, 2007 Share Posted March 13, 2007 hey, i hate to steal your thunder but is there a name for the -> function i googled it but nothing came up. I see those everywhere and they seem to make code a lot cleaner. i wish i could help, but i probably got a couple more years till i can make something half as good as that. HotDaWg Quote Link to comment Share on other sites More sharing options...
caseyh Posted March 13, 2007 Author Share Posted March 13, 2007 lol its alright, my code is actually pretty crappy to what a real guru can do, I found a topic that is just about explaining what the -> operator does, Just Click Here Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted March 13, 2007 Share Posted March 13, 2007 thankk yoooouuuuuuu i have been lookin for so long. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.