3) { $date_err="Error: Invalid date field. Too many fields (".count($datesplit).") found"; return $date_err; } if (strlen($datesplit[2])==4) { // The year is listed last - switch fields around $newdatesplit[0]=$datesplit[2]; // Move Year to first field $newdatesplit[1]=$datesplit[0]; // Move Month to second field $newdatesplit[2]=$datesplit[1]; // Move Day to third field $datesplit=$newdatesplit; } elseif (strlen($datesplit[0])==4) { // The year is first listed - do nothing // nothing to be done } else { // Date entered is not valid; could not find year field $date_err="Error: Date not valid. No Year field found (Year must be 4 digits)"; return $date_err; } if ($datesplit[1]>12) { // No valid month field $date_err="Error: Invalid Month field (".$datesplit[1].") "; return $date_err; } else { switch ($datesplit[1]) { // Check number of days in a month case 4: case 6: case 9: case 11: if ($datesplit[2]>30) { $date_err="Error: Invalid # of days (".$datesplit[2].") for month ".$datesplit[1]." and year ".$datesplit[0]; return $date_err; } break; case 2: // February Check if (($datesplit[0]/4)==(floor($datesplit[0]/4))) { if (($datesplit[0]/100)==(floor($datesplit[0]/100))) { if (($datesplit[0]==1600) or ($datesplit[0]==2000) or ($datesplit[0]==2400)) { if ($datesplit[2]>29) { $date_err="Error: Invalid # of days (".$datesplit[2].") for month ".$datesplit[1]." and year ".$datesplit[0]; return $date_err; } } else { if ($datesplit[2]>28) { $date_err="Error: Invalid # of days (".$datesplit[2].") for month ".$datesplit[1]." and year ".$datesplit[0]; return $date_err; } } } else { if ($datesplit[2]>29) { $date_err="Error: Invalid # of days (".$datesplit[2].") for month ".$datesplit[1]." and year ".$datesplit[0]; return $date_err; } } } else { if ($datesplit[2]>28) { $date_err="Error: Invalid # of days (".$datesplit[2].") for month ".$datesplit[1]." and year ".$datesplit[0]; return $date_err; } } break; default: if ($datesplit[2]>31) { $date_err="Error: Invalid # of days (".$datesplit[2].") for month ".$datesplit[1]." and year ".$datesplit[0]; return $date_err; } } } if (strlen($datesplit[1])==1) { $datesplit[1]="0".$datesplit[1]; } if (strlen($datesplit[2])==1) { $datesplit[2]="0".$datesplit[2]; } $newdate=$datesplit[0]."-".$datesplit[1]."-".$datesplit[2]; return $newdate; } // End date_validate function function Perform_Select_Query ($SQL, $db) { $Query = mysql_db_query($db, $SQL); $my_err=mysql_error(); if ($my_err) { $my_err = "Error: ".$my_err; mysql_free_result ($Query); return $my_err; } else { $row=0; $num_fields = mysql_num_fields($Query); for ($i=0;$i < $num_fields; $i++) { $fieldname[$i]=mysql_field_name($Query,$i); } while ($result_array_1 = mysql_fetch_array($Query)) { for ($i=0;$i < $num_fields; $i++) { $this_fieldname = $fieldname[$i]; $result_array[$this_fieldname][$row] = $result_array_1[$this_fieldname]; } $row++; } mysql_free_result ($Query); return $result_array; } } function Get_Rows ($SQL, $db) { $Query = mysql_db_query($db, $SQL); $my_err=mysql_error(); if ($my_err) { $my_err = "Error: ".$my_err; mysql_free_result ($Query); return $my_err; } else { $Query_Rows = mysql_num_rows($Query); mysql_free_result ($Query); return $Query_Rows; } } function Get_Fields ($SQL, $db) { $Query=mysql_db_query($db, $SQL); $my_err=mysql_error(); if ($my_err) { $my_err = "Error: ".$my_err; mysql_free_result ($Query); return $my_err; } else { $num_fields = mysql_num_fields($Query); mysql_free_result ($Query); return $num_fields; } } function Get_Field_Names ($SQL, $db) { $Query=mysql_db_query($db, $SQL); $my_err=mysql_error(); if ($my_err) { $my_err = "Error: ".$my_err; mysql_free_result ($Query); return $my_err; } else { $num_fields = mysql_num_fields($Query); for ($i=0; $i<$num_fields; $i++) { $field[$i] = mysql_fetch_field ($Query); } mysql_free_result ($Query); return $field; } } function Perform_Query ($SQL, $db) { $Query = mysql_db_query($db, $SQL); $my_err=mysql_error(); if ($my_err) { $my_err = "Error: ".$my_err; } return $my_err; } if ($Submit) { $dbname="ate9ten_Hort"; $dbuser="ate9ten_theBoss"; $dbpass="2Bind4u2"; $hostname="mysql.websitesource.net"; $lnk = mysql_connect($hostname, $dbuser, $dbpass); $lnk1 = mysql_select_db($dbname); if (!$Error) { $SQL="INSERT INTO hort ( ID, PlantType, PlantFamily, LatinName, CommonName, Origin, Light, Soil, Moisture, FloweringTime, FlowerColor, Height, Fertilize, Propagation, USZone, Notes) VALUES ('$IDadd', '$PlantTypeadd', '$PlantFamilyadd', '$LatinNameadd', '$CommonNameadd', '$Originadd', '$Lightadd', '$Soiladd', '$Moistureadd', '$FloweringTimeadd', '$FlowerColoradd', '$Heightadd', '$Fertilizeadd', '$Propagationadd', '$USZoneadd', '$Notesadd')"; $SQL_Result = Perform_Query($SQL, $dbname); if (substr($SQL_Result, 0, 5)=="Error") $Error=1; } // End of Submit Section } /********************END MAIN PHP SECTION*********************/ ?> **********/ ?>
Error In Submission: '; exit; ?>
Add Database Info
ID:
PlantType:
PlantFamily:
LatinName:
CommonName:
Origin:
Light:
Soil:
Moisture:
FloweringTime:
FlowerColor:
Height:
Fertilize:
Propagation:
USZone:
Notes: