Variable errors |
Hey all!
I added some code to my site and it works, however I get hit with these dang gone undefined variable errors ![]() A PHP Error was encountered Severity: Notice Message: Undefined variable: buddy Filename: views/view_chat.php Line Number: 11 Backtrace: File: /home4/cultured/public_html/application/views/view_chat.php Line: 11 Function: _error_handler File: /home4/cultured/public_html/application/controllers/Register.php Line: 63 Function: view File: /home4/cultured/public_html/index.php Line: 315 Function: require_once x June 22, 2019
Severity: Notice Message: Use of undefined constant MAINSITE_URL - assumed 'MAINSITE_URL' Filename: views/view_chat.php Line Number: 16 Backtrace: File: /home4/cultured/public_html/application/views/view_chat.php Line: 16 Function: _error_handler File: /home4/cultured/public_html/application/controllers/Register.php Line: 63 Function: view File: /home4/cultured/public_html/index.php Line: 315 Function: require_once MAINSITE_URL/img/avatar/ A PHP Error was encountered Severity: Notice Message: Undefined variable: buddyimage Filename: views/view_chat.php Line Number: 16 Backtrace: File: /home4/cultured/public_html/application/views/view_chat.php Line: 16 Function: _error_handler File: /home4/cultured/public_html/application/controllers/Register.php Line: 63 Function: view File: /home4/cultured/public_html/index.php Line: 315 Function: require_once " /> A PHP Error was encountered Severity: Notice Message: Undefined variable: chat Filename: views/view_chat.php Line Number: 18 Backtrace: File: /home4/cultured/public_html/application/views/view_chat.php Line: 18 Function: _error_handler File: /home4/cultured/public_html/application/controllers/Register.php Line: 63 Function: view File: /home4/cultured/public_html/index.php Line: 315 Function: require_once Its for this code: <div class="headerchat"><div class="buddycontainer"> <?php echo $buddy; ?></div> <div class="closecontainer"><a href="#" id="closechat" class="close">x</a> </div> <br class="breaker" /> </div> <div align="right"><span class="gray"><?php echo date("F d, Y");?></span></div> <div class="conversationpicture"><img src="<?php echo MAINSITE_URL; ?>/img/avatar/<?php echo $buddyimage; ?>" /></div> <?php if (is_array($chat)) : Tried to define with a number but didnt think that was smart as well as define globally but that didint make a change at all ![]() Also these errors Im trying to fix as well: A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: views/DB.class.php Line Number: 72 For this code: if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; Error: A PHP Error was encountered Severity: Notice Message: A session had already been started - ignoring session_start() Filename: views/profile.php Line Number: 768 For this code: session_start(); A PHP Error was encountered Severity: Notice Message: Undefined index: email Filename: views/profile.php Line Number: 770 For this code: $email=$_SESSION['email']; A PHP Error was encountered Severity: Warning Message: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given Filename: views/profile.php Line Number: 774 For this code: while($row=mysqli_fetch_array($run)) Thank you for the help!! ![]() ![]() Mekaboo
What variables are being passed from controller to view?
If you need a variable named $buddy in your view, then the controller should have something like this: PHP Code: $data['buddy'] = "George"; CodeIgniter automatically extracts the array that you pass to a view. Look at the php documentation about the extract() function. Constants aren't variables. You'll have to define a constant before it can be used. If you need constants globally, you can define them in application/config/constants.php. Example: PHP Code: define('CURRENT_DATE_TIME', Date('Y-m-d H:i:s')); In CodeIgniter, you don't initiate the session the way you're used to in "plain php". Just autoload the session libary (in application/config/autoload.php). Then you can use $this->session-> ... the read and write session variables. (06-24-2019, 08:19 AM)Wouter60 Wrote: What variables are being passed from controller to view? Thanks for the help ![]() In regards to the buddy variable folks will be chatting with others who are within the DB, so should that be eliminated..I'm.trying to figure how do I add various names when it all depends on who registers with the site? Can the buddy variable be general? (06-24-2019, 08:19 AM)Wouter60 Wrote: What variables are being passed from controller to view? Sorry about that, re read the comment and saw that you spoke of global load in sessions, thanks again ![]() |
Welcome Guest, Not a member yet? Register Sign In |