This is a mix of PHP and MSSQL, I am wondering if this code below would work as printed or does it need editing? I wrote this perl script and now I am trying to convert it to PHP (per my company wishes). Any help would be greatly appreciated as I am not a guru with PHP or MSSQL yet.
$SQL=array(FirstName=>"$firstname",
LastName=>"$lastname",
Company=>"$company",
Address1=>"$address1",
Address2=>"$address2",
City=>"$city",
State=>"$state",
Zip=>"$zip",
PhoneHome=>"$homephone",
PhoneWork=>"$workphone",
PhoneFax=>"$faxphone",
RegionID=>"$form_region",
PayPeriodID=>"$form_payperiod",
PayMethodID=>"$PayMethodID",
CreditCardNumber=>"$CreditCardNumber",
CreditCardExpire=>"$CreditCardExpire"
);
# Create MBR
$query =
INSERT INTO MasterAccounts
(FirstName,LastName,Company,Address1,Address2,City,State,Zip,PhoneHome,PhoneWork,PhoneFax,
RegionID,Active,PayPeriodID,PayMethodID,GroupID,BillingCycleID,
Comments,LastModifyUser,BillDay,SendMethodID,SalesPersonID,Operator)
VALUES
('$SQL{FirstName}','$SQL{LastName}','$SQL{Company}','$SQL{Address1}','$SQL{Address2}',
'$SQL{City}','$SQL{State}','$SQL{Zip}','$SQL{PhoneHome}','$SQL{PhoneWork}','$SQL{PhoneFax}',
$SQL{RegionID},1,$SQL{PayPeriodID},$SQL{PayMethodID},$GroupID,$BillingCycleID,
'On-Line SignUp from [$HTTP_REMOTE_ADDR]','signup',DATEPART(Day,getdate()),0,$SalesPersonID,'signup');
qh();
$query = "SELECT @@IDENTITY";
qh();
if ($rows = @mysql_num_rows($result) == 0)
{
$query = "ROLLBACK TRANSACTION";
qh();
print ("Creating MasterAccount did not return CustomerID");
}else{
while ($row = mysql_fetch_array($result))
{
$customerid = $row[0];
}
}
Function qh() works properly.. The main portion of the query that I am questioning is the $SQL array.. Does the MSSQL INSERT VALUE portion look right? Do you pull values from php array like so? $SQL{FirstName} ??? Or does this look more correct? {$SQL["FirstName"]} ??
Thanks for help!
Tony Devlin