• PHP Help PHP Newbies
  • can anyone point me to a complete guide about implode/explode array to and from mysql

Hello All,

I have been working on a couple of things requiring the implode and explode function for a bout a week and still no cigar. I have had a lot of feedback from various people in various forums to try to help me out but unfortunately I ain't getting anywhere. Is there a good place where I can learn all there is to know about the explode and implode function from a form to mysql and back into the form calling back these values? Book? website? video? anything would be helpful. thanks a bunch

( please don't tell me to go look at php.net or at W3school, I obviously been there nothing of value in there. I need a complete walk through guide to truly understand how these functions work and how to use them in order to solve my problem. Everybody seems to have a different approach. I am looking for the good old classic method, no frill, no thrill.

    Jaady;11037161 wrote:

    Is there a good place where I can learn all there is to know about the explode and implode function from a form to mysql and back into the form calling back these values?

    Probably not, since [man]implode[/man] and [man]explode[/man] have nothing to do with forms or mysql. They are for converting arrays into strings and vice versa.

    Jaady;11037161 wrote:

    please don't tell me to go look at php.net or at W3school, I obviously been there nothing of value in there.

    It's not "obvious" at all. Advice: next time, skip w3schools entirely. But go back to php.net.

    Jaady;11037161 wrote:

    I need a complete walk through guide to truly understand how these functions work and how to use them in order to solve my problem

    Again, php.net. Since you don't give any details at all about what your problem is, I don't know what else you could expect.

    Which raises the question: since you're asking for help to solve a problem, why not tell us what your problem is?

      Honestly, the manual page for [man]explode/man fits the bill of the "approach" you described at the end of your post. It shows you the function prototype, gives a brief description of what it does, talks about its arguments, talks about what it returns, and comes complete with coding examples (not one but three in this case). If you can't figure it out from that... perhaps programming just isn't the hobby for you.

      EDIT: For example, have you tried looking at one of those three coding examples (better yet, all three) and understanding how it works?

        well one of the problem was to explode a value back into 3 input fields from where a value came from. I had picked up a neath little javascript utility that validate Canadian social insurance number and once it did that I concatenated the 3 values into one value to make a complete SIN number and saved it to mysql. I can't get the value back into the 3 field for edit. The other problem is to save the values of multi-checkboxes into mysql and then pull the value back out of the form to update by a user. People online all said, "oh well that's easy, here are you do it..." and a week later I'm still having the same problem with no solution lol. So I am just trying to figure this problem on my own because I don't think anyone can help me. Both case I get the same error or notice "an array is expected where none is provided. in both cases I was able to build a prototype that worked. the problem is to find a line of code that will call back the value from mysql and that what got everyone who have tried helping me baffled. I just want to try to move on from this problem, a week is a long time to search for a solution.

          If you can't figure it out from that... perhaps programming just isn't the hobby for you.

          That's not fair man. I get it! I even wrote prototype with static value to test it and it works fine. It's getting the data from mysql and back into the form that I can't solve, That nobody can solve, the dozen of different people who have tried to help out couldn't figure it out either. If anything, give me some credit for having the will of trying to solve this after a week of going back and forth with this.

            In that case, it sounds like you have a bigger problem in that you can't properly decompose a problem into small pieces and solve them one by one. As mentioned above, explode() and MySQL and forms have nothing to do with one another - they're three different topics, each orthogonal to the other two.

              In that case, it sounds like you have a bigger problem in that you can't properly decompose a problem into small pieces and solve them one by one.

              That is eactly what I am trying to do by understanding each step and figuringing out where the problem is. I know that my form works because it saves the value, I know that the call back sql works because everything else on the form gets updated. the problem lies at the explode() function stage because I am not getting any array out and that is why I am trying to figure the ins- and out of explode() to eliminate every possible aspect that might be the problem.

                It can help to actually describe the problem, rather than just say that you have a problem. Provide the code that isn't working, show the data that goes into it, show what comes out, show what should be coming out. Basically, don't assume that everyone can just look over your shoulder to see what you're doing on your computer.

                "I tried something and it didn't work!"
                "Then something must be broken."

                  ok well, this is from the last gentleman who tried helping me: I am posting the whole page so everyone can see about everything:

                  	<?php			$first_name 	= htmlentities(trim($_POST['first_name']));
                  					$last_name 		= htmlentities(trim($_POST['last_name']));
                  					$middle_name	= htmlentities(trim($_POST['middle_name']));	
                  					$gender 		= htmlentities(trim($_POST['gender']));
                  					//$dob	 		= htmlentities(trim($_POST['dob']));
                  					$sin			= htmlentities(trim($_POST['sin']));
                  					$home_phone		= htmlentities(trim($_POST['home_phone']));
                  					$cell_phone		= htmlentities(trim($_POST['cell_phone']));
                  					$emerg_name		= htmlentities(trim($_POST['emerg_name']));
                  					$emerg_email	= htmlentities(trim($_POST['emerg_email']));
                  					$emerg_phone	= htmlentities(trim($_POST['emerg_phone']));
                  					$co_app 		= implode(',', $_POST['co_app']);
                  					$co_name		= htmlentities(trim($_POST['co_name']));
                  					$bio 			= htmlentities(trim($_POST['bio']));
                  					$image_location	= htmlentities(trim($newpath));
                  					$co_app 		= explode(',', $_POST['co_app']);
                  
                  
                  
                  		$users->update_user($first_name, $middle_name, $last_name, $gender, $dob, $sin, $home_phone, $cell_phone, $emerg_name,$emerg_email, $emerg_phone, $co_app, $co_name, $bio, $image_location, $user_id);
                  				header('Location: settings.php?success');
                  				exit();
                  
                  			} else if (empty($errors) === false) {
                  				echo '<p>' . implode('</p><p>', $errors) . '</p>';	
                  			}	
                          }
                  
                  		?>
                  
                  		<h2>Settings.</h2> <p><b>Note: Information you post here is made viewable to others.</b></p>
                          <hr />
                  
                          <form action="" method="post" enctype="multipart/form-data">
                              <div id="profile_picture">
                  
                  
                  
                                        <input type="checkbox" name="co_app[]" value="spouse" <?= (array_key_exists('co_app', $_POST) && in_array('spouse', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>> Spouse
                                        <input type="checkbox" name="co_app[]" value="roommate" <?= (array_key_exists('co_app', $_POST) && in_array('roommate', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>> Roommate
                                        <input type="checkbox" name="co_app[]" value="none" <?= (array_key_exists('co_app', $_POST) && in_array('none', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>> None
                  
                                      </li>
                                      <li>
                                          <h4>Co-Applicant Name:</h4>
                                          <input type="text" name="co_name" onKeyPress="return disableEnterKey(event)" value="<?php if (isset($_POST['co_name']) ){echo htmlentities(strip_tags($_POST['co_name']));} else { echo $user['co_name']; }?>">
                                      </li>
                                      <li>
                                          <h4>Bio:</h4>
                                          <textarea name="bio"><?php if (isset($_POST['bio']) ){echo htmlentities(strip_tags($_POST['bio']));} else { echo $user['bio']; }?></textarea>
                                      </li>
                              	</ul>    
                          	</div>
                          	<div class="clear"></div>
                          	<hr />
                          		<span>Update Changes:</span>
                                  <input type="submit" value="Update">
                  
                          </form>
                  </div>
                  
                  </body>
                  </html>
                  <?php
                  		}

                  And this is my update-user function

                  <?php 
                  class Users{
                  
                  private $db;
                  
                  public function __construct($database) {
                      $this->db = $database;
                  }	
                  
                  public function update_user($first_name, $middle_name, $last_name, $gender, $dob, $sin,$home_phone, $cell_phone, $emerg_name,$emerg_email, $emerg_phone, $co_app, $co_name, $bio, $image_location, $id){
                  
                  
                  
                  	$query = $this->db->prepare("UPDATE `users` SET
                  							`first_name`	= ?,
                  							`middle_name`	= ?,
                  							`last_name`		= ?,
                  							`gender`		= ?,
                  							`dob`			= ?,
                  							`sin`			= ?,
                  							`home_phone`	= ?,
                  							`cell_phone`	= ?,
                  							`emerg_name`	= ?,
                  							`emerg_email`	= ?,
                  							`emerg_phone`	= ?,
                  							`co_app`		= ?,
                  							`co_name`		= ?,
                  							`bio`			= ?,
                  							`image_location`= ?
                  
                  							WHERE `id` 		= ? 
                  							");
                  
                  	$query->bindValue(1, $first_name);
                  	$query->bindValue(2, $middle_name);
                  	$query->bindValue(3, $last_name);
                  	$query->bindValue(4, $gender);
                  	$query->bindValue(5, $dob);
                  	$query->bindValue(6, $sin);
                  	$query->bindValue(7, $home_phone);
                  	$query->bindValue(8, $cell_phone);
                  	$query->bindValue(9, $emerg_name);
                  	$query->bindValue(10, $emerg_email);
                  	$query->bindValue(11, $emerg_phone);
                  	$query->bindValue(12, $co_app);
                  	$query->bindValue(13, $co_name);
                  	$query->bindValue(14, $bio);
                  	$query->bindValue(15, $image_location);
                  	$query->bindValue(16, $id);
                  
                  	try{
                  		$query->execute();
                  
                  	}catch(PDOException $e){
                  		die($e->getMessage());
                  	}
                  
                  }
                  
                  

                  [/code]

                    sorry I had to cut off some parts because the character limit was reached

                      is there an "edit post" button somewhere?

                        Anyway, this last attempt that someone tried to help me with was creative but unfortunately now the script doesn't write to mysql and,well, obviously nothinig is coming back in the user edit profile page either

                        here is a clearer view of the code the tag got deleted lat post

                        	$first_name 	= htmlentities(trim($_POST['first_name']));
                        					$last_name 		= htmlentities(trim($_POST['last_name']));
                        					$middle_name	= htmlentities(trim($_POST['middle_name']));	
                        					$gender 		= htmlentities(trim($_POST['gender']));
                        					//$dob	 		= htmlentities(trim($_POST['dob']));
                        					$sin			= htmlentities(trim($_POST['sin']));
                        					$home_phone		= htmlentities(trim($_POST['home_phone']));
                        					$cell_phone		= htmlentities(trim($_POST['cell_phone']));
                        					$emerg_name		= htmlentities(trim($_POST['emerg_name']));
                        					$emerg_email	= htmlentities(trim($_POST['emerg_email']));
                        					$emerg_phone	= htmlentities(trim($_POST['emerg_phone']));
                        					$co_app 		= implode(',', $_POST['co_app']);
                        					$co_name		= htmlentities(trim($_POST['co_name']));
                        					$bio 			= htmlentities(trim($_POST['bio']));
                        					$image_location	= htmlentities(trim($newpath));
                        					$co_app 		= explode(',', $_POST['co_app']);
                        $users->update_user($first_name, $middle_name, $last_name, $gender, $dob, $sin, $home_phone, $cell_phone, $emerg_name,$emerg_email, $emerg_phone, $co_app, $co_name, $bio, $image_location, $user_id);
                        					header('Location: settings.php?success');
                        					exit();
                        
                        			} else if (empty($errors) === false) {
                        				echo '<p>' . implode('</p><p>', $errors) . '</p>';	
                        			}	
                                }
                        
                        		?>
                        
                        		<h2>Settings.</h2> <p><b>Note: Information you post here is made viewable to others.</b></p>
                                <hr />
                        
                                <form action="" method="post" enctype="multipart/form-data">
                        
                                            <li>
                                                <h4>Co-Application:</h4>
                        
                                              <input type="checkbox" name="co_app[]" value="spouse" <?= (array_key_exists('co_app', $_POST) && in_array('spouse', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>> Spouse
                                              <input type="checkbox" name="co_app[]" value="roommate" <?= (array_key_exists('co_app', $_POST) && in_array('roommate', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>> Roommate
                                              <input type="checkbox" name="co_app[]" value="none" <?= (array_key_exists('co_app', $_POST) && in_array('none', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>> None
                        
                                            </li>
                        
                        

                          But where is the form field named "sin"? And where are the explode and/or implode calls you're complaining about? They're not going to work if they're not there.

                            jaady wrote:
                              $co_app         = explode(',', $_POST['co_app']); 
                            $users->update_user($first_name, $middle_name, $last_name, $gender, $dob, $sin, $home_phone, $cell_phone, $emerg_name,$emerg_email, $emerg_phone, $co_app, $co_name, $bio, $image_location, $user_id); 

                            Does the method "update_user" EXPECT to receive an array as its tenth parameter?

                              I did some research late last night and changed that explode line to:

                              if(isset($_POST['submit']))
                              				{
                              					if(isset($_POST['co_app']))
                              					{
                              					$explodecoapp = explode(',',$_POST['co_app']);
                              					}
                              					else
                              					{
                              					$explodecoapp = "";
                              					}	
                              				}
                              

                              I also was able to fix the implode function to write to the database by changing the form and eliminating the code of the last person who tried to help me.

                              <h4>Co-Application:</h4>
                              
                                                    <input type="checkbox" name="co_app[]"  value="spouse"> Spouse
                                                    <input type="checkbox" name="co_app[]"  value="roommate"> Roommate
                                                    <input type="checkbox" name="co_app[]"  value="none"> None
                              

                              so as you can see I am half way there. I fix two problems and now I am at the last step. Trying to find a line of code to insert into the value of the input field to call the value in the database.

                              As a side note guy. I only been working in php for about a month. I started doing web programing for 3 months and learned html and css first and now I am in php. I work full time at another job but still managed to put at least 8 to 12 hours a day 7 days a week learning about this stuff. And the mistakes that you might see in my codes are due becuase of lack of experience and also because I followed the instruction of others online who were good enough to try to help me as best they can. but as you can imagine not everyone who offer help are master in the field and them too make mistakes, it's all a learning curve.

                                Back up a second. You're still starting your explanation somewhere in the middle. Tell us:

                                • what you are trying to accomplish (your goal)
                                • what you have already done
                                • what you expected to happen
                                • what actually happened

                                Be specific and detailed.

                                Are you talking about the [font=monospace]co_app[/font] field(s)? My wild guess after reading your previous posts:

                                • You're trying to read the three "co_app" checkboxes from your form, and save them in your DB.

                                • You tried concatenating them into a single string (e.g., "spouse,roommate,none") and saving them all in a single field. If this is the case, it doesn't make sense.

                                First off, it is logically impossible for "none" to be chosen along with either of the other two values. I am assuming that this choice should really be "spouse | roommate | both | neither."

                                Second, saving multiple values in a single field defeats the purpose of organizing data in a database. Different values need to be in different fields.

                                Does the spouse/roommate share this application? or do they have their own, separate (but related) application? In the latter case, you shouldn't be storing the "co_app" info here at all; it should be in an intersection table (a table which stores only the relationships between different applications).

                                • I'm not quite sure what you expected to happen. I am also unsure about where implode/explode come in: it looks like you were trying to turn concatenated checkboxes back into an array…? But then, as @ pointed out, you cannot save a PHP array in a relational database.

                                As a side note, I would probably approach those checkboxes as

                                <input type=checkbox name=co_app[spouse] value=1>
                                <input type=checkbox name=co_app[roommate] value=1>

                                SO, let us know how much (if any) of this guesswork is correct, and then share the code you're actually using (what you are most satisfied with: what seems to work best, and what you understand and can explain; not necessarily what someone else gave you). It would probably help to see your database schema as well.

                                  Cool! I love your style man. You seem to have the organizational skill that I been looking to learn from. thanks a bunch for taking the time to go in depth with my problem, That makes you a really cool dude. ok lets take it by the number.

                                  first, a rational:

                                  I operate facilities where people lease units. For a new tenant to lease a unit with me they have to submit an application form (this is what I am currently building, the application form.)
                                  Part of the process of the application is to indicate the number of people that will co-lease either as a spouse, a roommate/or/ as a roomate who will share the lease, or as a roommate that will not share the lease or "none"- Which mean only one person signing the lease and nobody else will be living in the unit with the applicant. This should explain the "none" you were questioning.

                                  Where I am at the moment is the checkbox section that an applicant must choose. The header reads "Lease Co-application" []spouse []roommate []none. there will be another section that will deal with roommates that aren't singing the lease but will live in the unit.

                                  my goal:
                                  to have 3 checkboxes a tenant can choose. it cannot be radio buttons because a couple may sign a lease and also have a roommate who also will be signing on the lease.

                                  what I have accomplished so far:

                                  I have my 3 checkboxes in my form - this works
                                  I implode the result of the 3 checkboxes and save it into my database in a field calledco_app. This is perfectly acceptable in a normalized table because I don't need to go any further with this value. it's purely informational. The relationship of the application with all users happens at the location level or by unit_ID which is a child table of building_ID. Tenants, also get a Symbiosis_ID, an alias because a tenant may live in one unit one day and move to another unit the next day or move to another one of my buildings. this alias allows me to keep all journal entried, maintenance request, complaints, rent payment with one unit and one unit only. if the tenant move then his information stay the same I only assign a new symbiosis_id to the relationship between the tenant and the new unit without losing anything reference to where that tenant lived before this creating a history with the user as long as he live in our properties. Anyway it is fairly complex to explain and it has no bearing here. suffice to say that all my tables (about 80 of them have all been setup to the normal 1-2-3.)

                                  1- my goal at this time - To have the imploded value of co_app be re-populated into the user's profile when the user needs to go make changes to the application. at this time I can't call back the checkmarks back into the checkboxes.

                                  "your last point "You cannot save an array to a relational database" Of course you can save an array to a rational database, what are you talking about? I have about 12 tables where I store arrays, it's very useful once you know how to extract the data. My background is woth MS access. I built this application that I am trying to reproduce online. I been using it for 3 years and it is fantastic. the problem is... it's a desktop application, it's useless nowaday where everythign happen online and with smartphone. this is why I decided to learn how to web program, so I can rebuild my application online.

                                    Jaady;11037201 wrote:

                                    I operate facilities where people lease units. For a new tenant to lease a unit with me they have to submit an application form (this is what I am currently building, the application form.)
                                    Part of the process of the application is to indicate the number of people that will co-lease either as a spouse, a roommate/or/ as a roomate who will share the lease, or as a roommate that will not share the lease or "none"- Which mean only one person signing the lease and nobody else will be living in the unit with the applicant. This should explain the "none" you were questioning.

                                    Where I am at the moment is the checkbox section that an applicant must choose. The header reads "Lease Co-application" []spouse []roommate []none. there will be another section that will deal with roommates that aren't singing the lease but will live in the unit.

                                    This actually brings up another question. It has more to do with the application itself, not the html or the database, but: are multiple roommates allowed? For example, two roommates? a spouse and two roommates? Your current checkbox design can't accommodate this: you would need to have a range input, so users can choose the number of roommates. This would definitely affect how you design the form, your php script, and the database as well.

                                    I take it that there is only one application, regardless of how many people are co-signing?

                                    The "none" option is still problematic. Whether you intend it or not, someone can check (for example) "roommate" and "none." If this is not allowed, then it shouldn't be possible.

                                    Jaady;11037201 wrote:

                                    I implode the result of the 3 checkboxes and save it into my database in a field calledco_app. This is perfectly acceptable in a normalized table because I don't need to go any further with this value.

                                    If you insist (though I can easily imagine needing to sort rentals by number or type of co-signers—updates to the agreement, for example).

                                    And no, it is (by definition) not acceptable in a normalized table (I understand that it may be acceptable to you, and I won't argue that point).

                                    Jaady;11037201 wrote:

                                    "your last point "You cannot save an array to a relational database" Of course you can save an array to a rational database, what are you talking about?

                                    You can store representations of an array (a CSV, JSON, etc.), yes. You could also store the values that comprise the array, and define the structure in some way. You cannot store the actual array itself.

                                    Jaady;11037201 wrote:

                                    The relationship of the application with all users happens at the location level or by unit_ID which is a child table of building_ID. Tenants, also get a Symbiosis_ID, an alias because a tenant may live in one unit one day and move to another unit the next day or move to another one of my buildings. this alias allows me to keep all journal entried, maintenance request, complaints, rent payment with one unit and one unit only. if the tenant move then his information stay the same I only assign a new symbiosis_id to the relationship between the tenant and the new unit without losing anything reference to where that tenant lived before this creating a history with the user as long as he live in our properties.

                                    This almost makes it sound like the co_app information is redundant…?

                                    But, if you're happy with it, that's fine. Moving on:

                                    Jaady;11037201 wrote:

                                    my goal at this time - To have the imploded value of co_app be re-populated into the user's profile when the user needs to go make changes to the application. at this time I can't call back the checkmarks back into the checkboxes.

                                    So, the "co_app" field is already saved to the DB, in a CSV format, and you want to separate it back into its component values. Correct?

                                    <?php
                                    //  . . .
                                    
                                    # split db record on commas
                                    $co_apps = explode( ",",$row["co_app"] );
                                    
                                    # set a var for each possible option
                                    $co_app["spouse"]   = in_array( "spouse"  ,$co_apps )? "checked": "";
                                    $co_app["roommate"] = in_array( "roommate",$co_apps )? "checked": "";
                                    $co_app["none"]     = in_array( "none"    ,$co_apps )? "checked": "";
                                    
                                    //  . . .
                                    ?>
                                    
                                    <!-- apply "checked" attribute (or not) -->
                                    <input type=checkbox name=co_app[] value=spouse   <?= $co_app["spouse"]   ?>>
                                    <input type=checkbox name=co_app[] value=roommate <?= $co_app["roommate"] ?>>
                                    <input type=checkbox name=co_app[] value=none     <?= $co_app["none"]     ?>>

                                    Creating a CSV from the input array would be like:

                                    <?php
                                    
                                    $co_apps = implode( ",",$_POST["co_app"] );

                                    (Note this is different than your example in post #15: you cannot use explode on $_POST["co_app"] because it is already an array.)

                                    Again, if you need more than this, you'll need to share the code you are using.

                                      are multiple roommates allowed? For example, two roommates? a spouse and two roommates? Your current checkbox design can't accommodate this: you would need to have a range input, so users can choose the number of roommates. This would definitely affect how you design the form, your php script, and the database as well.

                                      You make a compelling point there and I agree with you in essence. Don't forget that this is only an application form. The real form where all the T will be crossed and i dotted will happen on the second step of this application/lease process. Where I live in British Columbia, the British Columbia Tenancy Act works a certain way that is different than anywhere else in Canada or in the world for that matter. There are guidelines and then their are rules. The application itself is formulated upon guidelines and doesn't need to be to involved. When I go through tons of Tenancy Application and for me I don't need it too detailed because some people don't have the attention span to fill-in an application and if I go overboard with questions I might lose a tenant who only has to provide last address and landlord info with employment history. So I agree with you on what you say but I chose not to implement it for practical reason.

                                      I take it that there is only one application, regardless of how many people are co-signing?

                                      yes only one application. all people who will live in the unit have to sign the hardcopy anyway. So it doesn't matter to me if two or three or no roommate tic the co_app check box. it is just a quick visual queue for me to glance at when I visually scan quickly the application. I have several queue setup in my application to speed up the process. Things you learn in time by doing it over and over again, or experience.

                                      The "none" option is still problematic. Whether you intend it or not, someone can check (for example) "roommate" and "none." If this is not allowed, then it shouldn't be possible.

                                      you are right about that; good observation! on paper people would usually scratch one if they made a mistake but electronic form can't be scratched and it will submit so I will need to think about validating the combination set for that. thanks.

                                      If you insist (though I can easily imagine needing to sort rentals by number or type of co-signers—updates to the agreement, for example).

                                      you are right but I would not do it at that level. Each person that will be on the lease will need to enter their own information, thus everyone gets a userid. I need to have it setup this way because of legalities. I also need to keep tract of every individual because everyone is fluid within a rental agreement. Their might be spouses one day but then a divorce comes. who gets the apartment? who gets the damage deposit back? what if the roomate punched a hole in the wall, who is paying for that? complaints are made who was it that was responsible? as you can see there are hundreds of different scenario which forces me to have everyone sign as a unique individual. the only thing they will have in common is the foreign key unit_ID.

                                      Your code looks awesome. I am going to try them up and if I dont get teh expected result I will post in chunck my whole page and my classes. (they dont allow more than so many character per post so I will have to break it up in bits. I will get back to you. And once again Muchas Gracias amigo. you are awesome and definitly deserve a cold beer if you ever come around my part of the world.

                                        ok, I am getting the following Notice:

                                        Co-Application:
                                        Notice: Undefined variable: co_app in C:\xampp\htdocs\lar\settings.php on line 306
                                        Notice: Undefined variable: co_app in C:\xampp\htdocs\lar\settings.php on line 307
                                        Notice: Undefined variable: co_app in C:\xampp\htdocs\lar\settings.php on line 308

                                        Here is my full page broken down in sections. I will post the rest in another message following this one:

                                        this is the Head:

                                        <?php 
                                        include_once 'core/init.php';
                                        $general->logged_out_protect();
                                        ?>
                                        <!doctype html>
                                        <html lang="en">
                                        <head>
                                        	<meta charset="UTF-8">
                                        	<link rel="stylesheet" type="text/css" href="css/style.css" >
                                        	<title>Settings</title> 
                                        
                                        
                                        <script>
                                        
                                        function disableEnterKey(e){
                                        	var key; 
                                        	if	(window.event)
                                        		key = window.event.keyCode;     //IE
                                        	else
                                        		key = e.which;     				//firefox
                                            if	(key == 13)
                                                return false;
                                        	else
                                                return true;
                                        }
                                        
                                        </script>
                                        <script type="text/javascript">
                                        // this is a javascript sin number checker from http://www.codingforums.com/showthread.php?t=279032
                                        
                                        // valid number examples 046-454-286   193-456-787   127-248-623
                                        
                                        var sin = 0;
                                        
                                        function validate(which,next) {
                                        var val = which.value;
                                        val = val.replace(/[^0-9]/g,"")
                                        which.value = val;
                                        next = "S" + next;
                                        if (val.length == 3) {
                                        document.getElementById(next).focus();
                                        }
                                        sin = document.getElementById("S1").value + document.getElementById("S2").value + document.getElementById("S3").value; 
                                        }
                                        
                                        function CheckNumber(sin) {  // sin is a string value
                                        var c = 0;
                                        
                                        if (sin.substring(0,3) == "000") {
                                        alert("Invalid SIN: SIN's can't start with 000.");
                                        document.getElementById("S1").value = "";  // clear the fields
                                        document.getElementById("S2").value = "";
                                        document.getElementById("S3").value = "";
                                        //document.getElementById("S1").focus();  // if required
                                        return false;
                                        }
                                        
                                        if (sin.length !=9) {
                                        alert ("You must complete all three fields!");
                                        return false;
                                        }
                                        
                                        // odd digits
                                        for (var i = 1; i<=9; i+=2) {
                                        c += Number(sin.charAt(i-1));
                                        }
                                        
                                        // even digits
                                        for (var i = 2; i <=8; i+=2) {
                                        var digit = Number(sin.charAt(i-1)) *2;
                                        if (digit >9) {digit = digit -9}
                                        c += digit;
                                        }
                                        
                                        sin = document.getElementById("S1").value + "-" + document.getElementById("S2").value + "-" +document.getElementById("S3").value; 
                                        
                                        if ((c%10) == 0) {
                                        alert ("The Social Insurance Number " + sin + " is valid");
                                        }
                                        else {
                                        alert ("The Social Insurance Number " + sin + " is NOT valid");
                                        return false;
                                        }
                                        
                                        }
                                        
                                        </script>
                                        </head>