MySQL Forums
Forum List  »  PHP

Adding data from ARRAY to database table
Posted by: Christopher E
Date: April 10, 2006 03:25PM

Hello All,

Could someone please help me!

Ok, this is what this script should do,

It querys a table for one record then it checks to see if the table that this record is going to be copyed to is there if not it creates it, then it copies that record to the table, but I am geting this error:

Parse error: syntax error, unexpected $end in D:\www\filtering.php on line 137

It also appears that NO data is being added to the table that is created by this code. There is five types of strings here 1 being letters, 2 being numbers, 3 being letters and numbers, 4 being a blank line, 5 being a line feed.

The EIN is a number
The PNO is letters and numbers
The State is letters
The Blanks is nothing
The Line_Feed is a linefeed
^^^^^^^^^^^^^^
The above information is for the insert area as this is where it would go wrong as the rest is used in other part of my development and it works. I say what these are just incase they need to be showen in a different way to work right using arrays to added to a database table.


Here is the code
******************************************************

<?php

//Set variables for Connecting to the database
$host = "localhost";
$user = "SEAS-Network";
$password = "**********";
$database = "seas";

$conn = mysql_connect($host, $user, $password) or die(mysql_error());
$db = mysql_select_db($database, $conn) or die(mysql_error());

// SELECTS and filters for matching or not matching criterias!
$SQL_SELECT_Table = "SELECT

EIN,
PNO,
ICN,
Street_Address,
City,
State,
Postal_Code,
GEN,
Subsection_Code,
Affiliation_Code,
Classification_Code,
Ruling_Date,
Deductibility_Code,
Foundation_Code,
Activity_Code,
Organization_Code,
UL_Code,
AFED,
Tax_Period,
Asset_Code,
Income_Code,
FR_Code,
Blanks,
Accounting_Period,
Asset_Amount,
Income_Amount,
IIANCNS_1,
F_990_RA,
IIANCNS_2,
NTEE_Code,
SN_SNL,
Line_Feed

FROM Non_Processed_Enities_Table
WHERE EIN = 943184503 ";

// Checks to see if there was a connection and table created if so goes on if not give error!
$res = mysql_query($SQL_SELECT_Table, $conn) or die('Error in filtering data '.mysql_error());

//Set variable to creat table if not existing
$SQL_CREATE_Table = "CREATE TABLE IF NOT EXISTS Processed_Enities
(
EIN int(9),
PNO varchar(70),
ICN varchar(35),
Street_Address varchar(35),
City varchar(22),
State char(2),
Postal_Code varchar(10),
GEN int(4),
Subsection_Code int(2),
Affiliation_Code int(1),
Classification_Code int(4),
Ruling_Date int(6),
Deductibility_Code int(1),
Foundation_Code int(2),
Activity_Code int(9),
Organization_Code int(1),
UL_Code int(2),
AFED int(6),
Tax_Period varchar(6),
Asset_Code int(1),
Income_Code int(1),
FR_Code int(3),
Blanks char(3),
Accounting_Period int(2),
Asset_Amount varchar(13),
Income_Amount varchar(13),
IIANCNS_1 char(1),
F_990_RA varchar(13),
IIANCNS_2 char(1),
NTEE_Code varchar(4),
SN_SNL varchar(35),
Line_Feed char(1)
)";

// Checks to see if there was a connection and table created if so goes on if not give error!
$res = mysql_query($SQL_CREATE_Table, $conn) or die('Error creating table '.mysql_error());

// setup counter to see how many rows are affected!
// $affected = 0;

// INSERT the information that has passed the criteria into the below table!
$SQL_INSERT_Processed_Enities_Data = "INSERT INTO Processed_Enities_Table SET

Processed_Enities_Table.EIN = $filted_results[EIN] ".
"Processed_Enities_Table.PNO = $filted_results[PNO] ".
"Processed_Enities_Table.ICN = $filted_results[ICN] ".
"Processed_Enities_Table.Street_Address = $filted_results[Street_Address] ".
"Processed_Enities_Table.City = $filted_results[City] ".
"Processed_Enities_Table.State = $filted_results[State] ".
"Processed_Enities_Table.Postal_Code = $filted_results[Postal_Code] ".
"Processed_Enities_Table.GEN = $filted_results[GEN] ".
"Processed_Enities_Table.Subsection_Code = $filted_results[Subsection_Code] ".
"Processed_Enities_Table.Affiliation_Code = $filted_results[Affiliation_Code] ".
"Processed_Enities_Table.Classification_Code = $filted_results[Classification_Code] ".
"Processed_Enities_Table.Ruling_Date = $filted_results[Ruling_Date] ".
"Processed_Enities_Table.Deductibility_Code = $filted_results[Deductibility_Code] ".
"Processed_Enities_Table.Foundation_Code = $filted_results[Foundation_Code] ".
"Processed_Enities_Table.Activity_Code = $filted_results[Activity_Code] ".
"Processed_Enities_Table.Organization_Code = $filted_results[Organization_Code] ".
"Processed_Enities_Table.UL_Code = $filted_results[UL_Code] ".
"Processed_Enities_Table.AFED = $filted_results[AFED] ".
"Processed_Enities_Table.Tax_Period = $filted_results[Tax_Period] ".
"Processed_Enities_Table.Asset_Code = $filted_results[Asset_Code] ".
"Processed_Enities_Table.Income_Code = $filted_results[Income_Code] ".
"Processed_Enities_Table.FR_Code = $filted_results[FR_Code] ".
"Processed_Enities_Table.Blanks = $filted_results[Blanks] ".
"Processed_Enities_Table.Accounting_Period = $filted_results[Accounting_Period] ".
"Processed_Enities_Table.Asset_Amount = $filted_results[Asset_Amount] ".
"Processed_Enities_Table.Income_Amount = $filted_results[Income_Amount] ".
"Processed_Enities_Table.IIANCNS_1 = $filted_results[IIANCNS_1] ".
"Processed_Enities_Table.F_990_RA = $filted_results[F_990_RA] ".
"Processed_Enities_Table.IIANCNS_2 = $filted_results[IIANCNS_2] ".
"Processed_Enities_Table.NTEE_Code = $filted_results[NTEE_Code] ".
"Processed_Enities_Table.SN_SNL = $filted_results[SN_SNL] ".
"Processed_Enities_Table.Line_Feed = $filted_results[Line_Feed];

// Checks to see if was able to connect and insert into table if so gives affected rows and if not gives error
$res = mysql_query($SQL_INSERT_Processed_Enities_Data, $conn) or die('Error copying query to table '.mysql_error());

mysql_close( $conn );
?>

------------------------------------------------------

Sincerely,
Christopher & Missy <--- InSpirt Now!

Options: ReplyQuote


Subject
Written By
Posted
Adding data from ARRAY to database table
April 10, 2006 03:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.