Please Help - why is my data not writing to the table?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

I really appreciate all of your time and help. It's not a very neat paste but I think it can be understood.

Below is the result of a show columns from ilmcompetition.pre_elementary

Field Type Null Key Default Extra
registrantNum int(10) unsigned NO PRI 0
name char(50) NO NULL
address char(100) NO NULL
city char(30) NO NULL
state char(20) NO NULL
zip char(5) NO NULL
phone char(14) NO NULL
dob date NO NULL
parent char(50) NO NULL
email char(50) NO NULL
partnerNum int(10) unsigned NO 1
pName char(50) NO NULL
pAddress char(100) NO NULL
pCity char(30) NO NULL
pState char(20) NO NULL
pZip char(5) NO NULL
pPhone char(14) NO NULL
pDob date NO NULL
pParent char(50) NO NULL
pEmail char(50) NO NULL
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

You've tried the following code using PDO as I showed you, and it's not working?

Code: Select all

$query = "
  INSERT INTO {$table_to_insert_to[$levels]} (
    registrant_num, name, address, city, state, zip, phone,
    dob, parent, email, pName, pAddress, pCity, pState, pZip,
    pPhone, pParent, pEmail
  ) VALUES (
    NULL, :name, :address, :city, :state, :zipcode, :phone,
    :dob, :parent, :email, :name2, :address2, :city2, :state2, :zipcode2,
    :phone2, :parent2, :email2
  )
";

$my_statement   = $con->prepare($query);
$my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zipcode"  => $zip1, // You had it referencing "zip", a non-token
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zipcode2" => $zip2, // again, referencing "zip2" instead of "zipcode"
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

I just copy pasted the exact code you gave me and got this output

Array ( [0] => 00000 )

then all of my echo statements followed.

I checked the database to see if anything wrote to it and it still shows zero records
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

i dont know if this helps but i'm using phpMyadmin on a linux server hosted by godaddy and i have it using php5

i created the tables with the phpMyadmin
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

Sorry to have you do this again, but please post your code where this insert statement is executing so I can have a look at the full thing to determine the nature of the problem.
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

Code: Select all

$con = new PDO("mysql:host=myhost;dbname=ilmcompetition", username, password) 
      or 
        die("Couldn't connect to specificied datasource.");
		
    // Create a tokenized query string to pass to our statement object.
/**
 * Array, instead of a switch:
 */
$query =  "
  INSERT INTO {$table_to_insert_to[$levels]} (
    registrant_num, name, address, city, state, zip, phone,
    dob, parent, email, pName, pAddress, pCity, pState, pZip,
    pPhone, pParent, pEmail
  ) VALUES (
    NULL, :name, :address, :city, :state, :zipcode, :phone,
    :dob, :parent, :email, :name2, :address2, :city2, :state2, :zipcode2,
    :phone2, :parent2, :email2
  )
";

$my_statement   = $con->prepare($query);
$my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zipcode"  => $zip1, // You had it referencing "zip", a non-token
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zipcode2" => $zip2, // again, referencing "zip2" instead of "zipcode"
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));

    if( !$my_result )
    {
      print_r($con->errorInfo());
    } 
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

From the looks of things, I would say it's because you're passing a NULL value to registrant_num and it isn't allowing NULL values...
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

ok, so then if I take that column off and that value off it should only write to the other columns and that should work right?
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

No. You'll need to supply a value to it, or allow NULLs in that field, or make that field auto_increment. When you insert a row, that field cannot be null.
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

I did set it to auto increment and thats why its set to not null
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

Ok. I may have overlooked that. In that case, don't supply a value, and don't include the column name in your columns predicate, and all should be bueno!
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

well i tried that but got the same array output and my echo's

I dont know...........i'm sort of on the verge of giving up here..........it seems that I just don't have the ability to do this program. If you have any other ideas, i'll try it though.

again, i appreciate your time!
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

Hmm. Let's have a few more attempts. I don't mind helping. If you're over it, that's all well and good, but maybe we can learn something here.

For the sake of discovery, would you post the entirety of your code here, as it is now, and I'll go through it.
ummhasan
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2010 7:24 pm
Location: USA

Re: Please Help - why is my data not writing to the table?

Post by ummhasan »

Ok, no problem....here's all the code...........there is a LOT of things I have commented out that I tried b4 and wasn't sure if I should just wipe out yet or not.

Code: Select all

	<?php
	
$con = new PDO("mysql:host=myhost_isreallymyhost;dbname=ilmcompetition", myUserNameIsReallyMyUserName, myPasswordIsReallyMyPassword) 
      or 
        die("Couldn't connect to specificied datasource.");
		
    // Create a tokenized query string to pass to our statement object.
/**
 * Array, instead of a switch:
 */
$query =  "
  INSERT INTO {$table_to_insert_to[$levels]} (
    name, address, city, state, zip, phone,
    dob, parent, email, pName, pAddress, pCity, pState, pZip,
    pPhone, pDob, pParent, pEmail
  ) VALUES (
    :name, :address, :city, :state, :zipcode, :phone,
    :dob, :parent, :email, :name2, :address2, :city2, :state2, :zipcode2,
    :phone2, :dob2, :parent2, :email2
  )
";

$my_statement   = $con->prepare($query);
$my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zipcode"  => $zip1, // You had it referencing "zip", a non-token
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zipcode2" => $zip2, // again, referencing "zip2" instead of "zipcode"
        "phone2"   => $ph2,
		"dob2"	   => $dob2,
        "parent2"  => $parentName2,
        "email2"   => $email2));

    if( !$my_result )
    {
      print_r($con->errorInfo());
    } 
[b]/*[/b]switch($levels)
{
   case "preE":
    $preE_status='checked';
    $query = "
      INSERT INTO pre_elementary (
        
      ) VALUES (
        
      )
    ";

    // prepare the statement for execution. When we execute the statement, we pass
    // an array containing the parameters we wish to use for our query (in the query,
    // these parameters are represented by tokens prefixed with ':')
    //
    // PDO will handle the data sanitizing for us with these two steps.

    $my_statement   = $p->prepare($query);
    $my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zip"  => $zip1,
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zip2" => $zip2,
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));

    if( !$my_result )
    {
      print_r($p->errorInfo());
    } 
break;	
case "elem": 
	$elem_status='checked';
	$query = "
      INSERT INTO elementary (
        id, name, address, city, state, zip, phone, dob, parent, email, 
        pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail
      ) VALUES (
        NULL, :name, :address, :city, :state, :zipcode, :phone, :dob, :parent, :email,
        :name2, :address2, :city2, :state2, :zipcode2, :phone2, :parent2, :email2
      )
    ";
	$my_statement   = $p->prepare($query);
    $my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zip"  => $zip1,
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zip2" => $zip2,
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));
break;
case "inter": 
	$inter_status='checked';
	$query = "
      INSERT INTO intermediate (
        id, name, address, city, state, zip, phone, dob, parent, email, 
        pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail
      ) VALUES (
        NULL, :name, :address, :city, :state, :zipcode, :phone, :dob, :parent, :email,
        :name2, :address2, :city2, :state2, :zipcode2, :phone2, :parent2, :email2
      )
    ";
	$my_statement   = $p->prepare($query);
    $my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zip"  => $zip1,
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zip2" => $zip2,
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));
break;
case "junior": 
	$junior_status='checked';
	$query = "
      INSERT INTO junior (
        id, name, address, city, state, zip, phone, dob, parent, email, 
        pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail
      ) VALUES (
        NULL, :name, :address, :city, :state, :zipcode, :phone, :dob, :parent, :email,
        :name2, :address2, :city2, :state2, :zipcode2, :phone2, :parent2, :email2
      )
    ";
	$my_statement   = $p->prepare($query);
    $my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zip"  => $zip1,
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zip2" => $zip2,
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));
break;
case "senior": 
	$senior_status='checked';   
	$query = "
      INSERT INTO junior (
        id, name, address, city, state, zip, phone, dob, parent, email, 
        pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail
      ) VALUES (
        NULL, :name, :address, :city, :state, :zipcode, :phone, :dob, :parent, :email,
        :name2, :address2, :city2, :state2, :zipcode2, :phone2, :parent2, :email2
      )
    ";
	$my_statement   = $p->prepare($query);
    $my_result      = $my_statement->execute(array(
        "name"     => $name1,
        "address"  => $address1,
        "city"     => $city1,
        "state"    => $state1,
        "zip"  	   => $zip1,
        "phone"    => $ph1,
        "dob"      => $dob1,
        "parent"   => $parentName1,
        "email"    => $email1,
        "name2"    => $name2,
        "address2" => $address2,
        "city2"    => $city2,
        "state2"   => $state2,
        "zip2"	   => $zip2,
        "phone2"   => $ph2,
        "parent2"  => $parentName2,
        "email2"   => $email2));
break;
*/
//create short variable names
	$name1=$_POST[name1];						$ph1=$_POST[ph1];				$dob1=$_POST[dob1];
	$parentName1=$_POST[parentName1];			$email1=$_POST[email1];			$address1=$_POST[address1];
	$city1=$_POST[city1];						$state1=$_POST[state1];			$zip1=$_POST[zip1]; 
	$name2=$_POST[name2];						$ph2=$_POST[ph2]; 				$dob2=$_POST[dob2];
	$parentName2=$_POST[parentName2];			$email2=$_POST[email2];			$address2=$_POST[address2];
	$city2=$_POST[city2];						$state2=$_POST[state2];			$zip2=$_POST[zip2];
	$levels=$_POST[levels];						$submit=$_POST[submit];
	
	$preE_status=$_POST[preE];					$elem_status=$_POST[elem];			$inter_status=$_POST[inter];
	$junior_status=$_POST[junior];				$senior_status=$_POST[senior];
	
/*add slashes before special charachters when input to database	
  if (!get_magic_quotes_gpc()) {
	$name1 = addslashes($name1);				$ph1 = addslashes($ph1);			$dob1 = addslashes($dob1);
	$parentName1 = addslashes($parentName1);	$email1 = addslashes($email1);		$address1 = addslashes($address1);
	$city1 = addslashes($city1);				$state1 = addslashes($state1);		$zip1 = addslashes($zip1);
	$name2 = addslashes($name2);				$ph2 = addslashes($ph2);			$dob2 = addslashes($dob2);
	$parentName2 = addslashes($parentName2);	$email2 = addslashes($email2);		$address2 = addslashes($address2);
	$city2 = addslashes($city2);				$state2 = addslashes($state2);		$zip2 = addslashes($zip2);
		}

   	   	$query="INSERT INTO pre_elementary (id, name, address, city, state, zip, phone, dob, parent, email, pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail)
	VALUES	(NULL, '".$name1."','".$ph1."','".$dob1."','".$parentName1."','".$email1."','".$address1."','".$city1."','".$state1."','".$zip1."','".$name2."','".$ph2."','".$dob2."','".$parentName2."','".$email2."','".$address2."','".$city2."','".state2."','".$zip2."'".$pPhone."','".$pParent."','".pEmail."')";
		$sql = "SELECT * FROM pre_elementary";
		mysql_query($sql,$con);
	
   		$query="INSERT INTO elementary (name, address, city, state, zip, phone, dob, parent, email, pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail)
	VALUES	(('".$name1."','".$ph1."','".$dob1."','".$parentName1."','".$email1."','".$address1."','".$city1."','".$state1."','".$zip1."','".$name2."','".$ph2."','".$dob2."','".$parentName2."','".$email2."','".$address2."','".$city2."','".state2."','".$zip2."'".$pPhone."','".$pParent."','".pEmail."')";
		
   		$query="INSERT INTO intermediate (name, address, city, state, zip, phone, dob, parent, email, pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail)
	VALUES	('".$name1."','".$ph1."','".$dob1."','".$parentName1."','".$email1."','".$address1."','".$city1."','".$state1."','".$zip1."','".$name2."','".$ph2."','".$dob2."','".$parentName2."','".$email2."','".$address2."','".$city2."','".state2."','".$zip2."'".$pPhone."','".$pParent."','".pEmail."')";
   	break;
	
   		$query="INSERT INTO junior (name, address, city, state, zip, phone, dob, parent, email, pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail)
	VALUES	('".$name1."','".$ph1."','".$dob1."','".$parentName1."','".$email1."','".$address1."','".$city1."','".$state1."','".$zip1."','".$name2."','".$ph2."','".$dob2."','".$parentName2."','".$email2."','".$address2."','".$city2."','".state2."','".$zip2."'".$pPhone."','".$pParent."','".pEmail."')";
     break;
   
	   	$query="INSERT INTO senior (name, address, city, state, zip, phone, dob, parent, email, pName, pAddress, pCity, pState, pZip, pPhone, pParent, pEmail)
	VALUES	('".$name1."','".$ph1."','".$dob1."','".$parentName1."','".$email1."','".$address1."','".$city1."','".$state1."','".$zip1."','".$name2."','".$ph2."','".$dob2."','".$parentName2."','".$email2."','".$address2."','".$city2."','".state2."','".$zip2."'".$pPhone."','".$pParent."','".pEmail."')";
   break;
   
   default:
   		echo "You did not select a level please go back and select a level.";
}
[b]*/[/b]
//field validation - if field is null user is asked to complete otherwise confirm and show entries
	 if (!$name1 || !$ph1 || !$dob1 || !$parentName1 || !$email1 || !$address1 || !$city1 || !$state1 || !$zip1) {
	 echo "You have not entered all the required information.  Please go back and fully complete the form.";
	 } elseif (!$levels) {
		 echo "You did not specify which level of competition you are entering.  Please go back and specify a level.";
	 } else {
	 echo "<h2>Jazak Allah Khair for registering, you will receive an email shortly with your registration number in sha Allah.</h2>";
	 echo "<p><strong>Your registration information is also below.</strong></p>";
	 echo "<table cellpadding='3'>";
	 echo "<tr><td>Name:&nbsp;".$name1."</td><td>Phone:&nbsp;".$ph1."</td><td>DOB:&nbsp;".$dob1."</td><td></td></tr>";
	 echo "<tr><td>Parent:&nbsp;".$parentName1."</td><td>Parent Email:&nbsp;".$email1."</td><td></td><td></td></tr>";
	 echo "<tr><td>Address:&nbsp;".$address1."</td><td>".$city1."</td><td>".$state1."</td><td>".$zip1."</td></tr></table>";
	 }
	 
	 if ($name2 || $ph2 || $dob2 || $parentName2 || $email2 || $address2 || $city2 || $state2 || $zip2) {
	 echo "<table cellpadding='3'><tr><td>Partners Name:&nbsp;".$name2."</td><td>Partners Phone:&nbsp;".$ph2."</td><td>Partners DOB:&nbsp;".$dob2."</td><td></td></tr>";
	 echo "<tr><td>Partners Parent:&nbsp;".$parentName2."</td><td>Partners Email:&nbsp;".$email2."</td><td></td><td></td></tr>";
	 echo "<tr><td>Partners Address:&nbsp;".$address2."</td><td>".$city2."</td><td>".$state2."</td><td>".$zip2."</td></tr>";
	 } else {
	 echo "<tr><td colspan='4'>You have choosed to enter without a partner - if you change your mind, please contact us via email.</td></tr></table>";
	 }
?>
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Please Help - why is my data not writing to the table?

Post by andyhoneycutt »

A couple of things: 1 - field validation should occur before you attempt to throw it into a database. 2 - you were missing the array declaration for which table to use based on user input. I'm hoping the below will help (although the code you posted was missing any type of form for input, maybe you can throw the rest together?)

Code: Select all

<?php
// field validation - if field is null user is asked to complete otherwise confirm 
// and show entries
if (!$name1 || !$ph1 || !$dob1 || !$parentName1 || !$email1 || !$address1 ||
    !$city1 || !$state1 || !$zip1)
{
  echo "You have not entered all the required information. " .
       "Please go back and fully complete the form.";
}
elseif (!$levels)
{
  echo "You did not specify which level of competition you are entering. " .
       "Please go back and specify a level.";
}
else
{
  //create short variable names
  $name1         = $_POST['name1'];
  $ph1           = $_POST['ph1'];
  $dob1          = $_POST['dob1'];
  $parentName1   = $_POST['parentName1'];
  $email1        = $_POST['email1'];
  $address1      = $_POST['address1'];
  $city1         = $_POST['city1'];
  $state1        = $_POST['state1'];
  $zip1          = $_POST['zip1'];
  $name2         = $_POST['name2'];
  $ph2           = $_POST['ph2'];
  $dob2          = $_POST['dob2'];
  $parentName2   = $_POST['parentName2'];
  $email2        = $_POST['email2'];
  $address2      = $_POST['address2'];
  $city2         = $_POST['city2'];
  $state2        = $_POST['state2'];
  $zip2          = $_POST['zip2'];
  $levels        = $_POST['levels'];
  $submit        = $_POST['submit'];
  $preE_status   = $_POST['preE'];
  $elem_status   = $_POST['elem'];
  $inter_status  = $_POST['inter'];
  $junior_status = $_POST['junior'];
  $senior_status = $_POST['senior'];
  
  /**
   * Array, instead of a switch:
   */
  $table_to_insert_to = array("preE"   => "pre_elementary",
                              "elem"   => "elementary",
                              "inter"  => "intermediate",
                              "junior" => "junior",
                              "senior" => "senior");
  
  $con = new PDO("mysql:host=myhost_isreallymyhost;dbname=ilmcompetition", myUserNameIsReallyMyUserName, myPasswordIsReallyMyPassword)
        or
          die("Couldn't connect to specificied datasource.");
                 
  // Create a tokenized query string to pass to our statement object.
  $query =  "
    INSERT INTO {$table_to_insert_to[$levels]} (
      name, address, city, state, zip, phone,
      dob, parent, email, pName, pAddress, pCity, pState, pZip,
      pPhone, pDob, pParent, pEmail
    ) VALUES (
      :name, :address, :city, :state, :zipcode, :phone,
      :dob, :parent, :email, :name2, :address2, :city2, :state2, :zipcode2,
      :phone2, :dob2, :parent2, :email2
    )
  ";
  
  $my_statement      = $con->prepare($query);
  $my_result         = $my_statement->execute(array(
          "name"     => $name1,
          "address"  => $address1,
          "city"     => $city1,
          "state"    => $state1,
          "zipcode"  => $zip1, // You had it referencing "zip", a non-token
          "phone"    => $ph1,
          "dob"      => $dob1,
          "parent"   => $parentName1,
          "email"    => $email1,
          "name2"    => $name2,
          "address2" => $address2,
          "city2"    => $city2,
          "state2"   => $state2,
          "zipcode2" => $zip2, // again, referencing "zip2" instead of "zipcode"
          "phone2"   => $ph2,
          "dob2"     => $dob2,
          "parent2"  => $parentName2,
          "email2"   => $email2));
  
  if( !$my_result )
  {
    print_r($con->errorInfo());
  }
  
  echo "<h2>Jazak Allah Khair for registering, you will receive an email shortly with your registration number in sha Allah.</h2>";
  echo "<p><strong>Your registration information is also below.</strong></p>";
  echo "<table cellpadding='3'>";
  echo "<tr><td>Name:&nbsp;".$name1."</td><td>Phone:&nbsp;".$ph1."</td><td>DOB:&nbsp;".$dob1."</td><td></td></tr>";
  echo "<tr><td>Parent:&nbsp;".$parentName1."</td><td>Parent Email:&nbsp;".$email1."</td><td></td><td></td></tr>";
  echo "<tr><td>Address:&nbsp;".$address1."</td><td>".$city1."</td><td>".$state1."</td><td>".$zip1."</td></tr></table>";
}

if ($name2 || $ph2 || $dob2 || $parentName2 || $email2 || $address2 || $city2 || $state2 || $zip2)
{
  echo "<table cellpadding='3'><tr><td>Partners Name:&nbsp;".$name2."</td><td>Partners Phone:&nbsp;".$ph2."</td><td>Partners DOB:&nbsp;".$dob2."</td><td></td></tr>";
  echo "<tr><td>Partners Parent:&nbsp;".$parentName2."</td><td>Partners Email:&nbsp;".$email2."</td><td></td><td></td></tr>";
  echo "<tr><td>Partners Address:&nbsp;".$address2."</td><td>".$city2."</td><td>".$state2."</td><td>".$zip2."</td></tr>";
}
else
{
  echo "<tr><td colspan='4'>You have choosed to enter without a partner - if you change your mind, please contact us via email.</td></tr></table>";
}
Post Reply