Page is a not externally linkable
Umm_Hasan - 11:51 pm on Mar 9, 2011 (gmt 0)
Hi all,
I have an html form that is processed with a php page which in turn inserts the user input to the mySQL db.
All data is inserting correctly BUT, an empty row is inserted *before* the data row. I had this problem before and it was due to my html form (I had accidently replaced a text statement with a semi colon - i dont know how - maybe my 2yr old pressed the key or somthing when it was highligheted) anyway, once I fixed that probelem all went well but my date was still not showing up.
To get the date to show in mySQL DATETIME field, I added a now() function to the Date field in my INSERT query.
Once I did this, all data including the date entered the DB properly BUT I started getting an extra empty row.
In addition to this, b4 adding the now() function and after adding it, I've been getting a mysql error like this:
Error: Duplicate entry '4' for key 1
I did look up that error and found that it seems to be a myphpadmin bug and there is a fix for it BUT, I have no idea how to apply that fix or patch to myphpadmin.
Any suggestions for both problems?
Here's the PHP:
$sql="INSERT INTO Registration2011 (Level, LastName, FirstName, Grade, DOB, eMail, Phone, Address, City, State, Zip, ParentsFirstName, ParentsLastName, Location, Date)
VALUES
('$level','$lname','$fname','$grade','$dob','$email','$ph','$addy','$city','$st','$zip','$ptFname','$ptLname','$location',now())";
mysql_query($sql);
$pid=mysql_insert_id();
$sql="INSERT INTO Partners2011 (ID, pLevel, PartnerLastName, PartnerFirstName, PartnerGrade, PartnerDOB, PartnerEmail, PartnerPhone, PartnerAddress, PartnerCity, PartnerState, PartnerZip, PartnerParentFirstName, PartnerParentLastName, Date)
VALUES
('$pid','$level','$pLname','$pFname','$pGrade','$pDob','$pEmail','$pPh','$pAddy','$pCity','$pSt','$pZip','$ppFname','$ppLname',now())";
mysql_query($sql);
if (!mysql_query($sql, $con))
{
die('Error: ' . mysql_error());
}
Here are the tables: CREATE TABLE `Registration2011` (
`ID` mediumint(10) NOT NULL auto_increment,
`Level` char(50) NOT NULL,
`LastName` char(50) NOT NULL,
`FirstName` char(50) NOT NULL,
`Grade` char(2) NOT NULL,
`DOB` char(10) NOT NULL,
`eMail` char(50) NOT NULL,
`Phone` char(15) NOT NULL,
`Address` char(100) NOT NULL,
`City` char(50) NOT NULL,
`State` char(10) NOT NULL,
`Zip` tinyint(5) NOT NULL,
`ParentsFirstName` char(50) NOT NULL,
`ParentsLastName` char(50) NOT NULL,
`Location` char(20) NOT NULL,
`Date` datetime NOT NULL,
PRIMARY KEY (`ID`),
KEY `Level` (`Level`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 CREATE TABLE `Partners2011` (
`ID` mediumint(10) NOT NULL,
`pLevel` char(50) NOT NULL,
`PartnerLastName` char(50) NOT NULL,
`PartnerFirstName` char(50) NOT NULL,
`PartnerGrade` char(2) NOT NULL,
`PartnerDOB` char(20) NOT NULL,
`PartnerEmail` char(50) NOT NULL,
`PartnerPhone` char(15) NOT NULL,
`PartnerAddress` char(100) NOT NULL,
`PartnerCity` char(20) NOT NULL,
`PartnerState` char(10) NOT NULL,
`PartnerZip` tinyint(5) NOT NULL,
`PartnerParentFirstName` char(50) NOT NULL,
`PartnerParentLastName` char(50) NOT NULL,
`Date` datetime NOT NULL,
PRIMARY KEY (`ID`),
CONSTRAINT `Partners2011_ibfk_1` FOREIGN KEY (`ID`) REFERENCES `Registration2011` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8