Hello All:
I have a DB collecting information from a form fine. However when no one enters an email nothing goes into the DB.
I thought i found the issue when I had the query for email set to unique, because then if another blank one would try to go in, it would not, made sense right.....
Nope, I set the NULL to YES and took out the UNIQUE requirement but it still will not go in if that field is blank or if the email is already in the DB.
Is there something that i am missing or that I could look for.
I am running MySQL - 4.1.20
Here is the php code for that query:
Code:$today = date("F j, Y, g:i a"); // Date Function //Define the Query $queryx = "SELECT email FROM customer_table WHERE email='$email' LIMIT 1"; // Check if the email exists in the table $resultx = mysql_query($queryx); if (mysql_num_rows($resultx) > 0) { $message = '<p><font color="red">Please use a different email address.</font></p>'; } else { $query = "INSERT INTO customer_table "; // Insert into table 'customer_table' $query .= "(First_Name, Last_Name, Company_Name, Address_Line_1, City, State, Postal_Code, Country, Custom_Field_1, Custom_Field_2, Custom_Field_3, Optin, email, List_Array, Parent, Date) "; $query .= "VALUES ('"; $query .= mysql_escape_string($First_Name) . "', '"; $query .= mysql_escape_string($Last_Name) . "', '"; // Last_Name is a unique field; the same email address will not be written to the table $query .= mysql_escape_string($Company_Name) . "', '"; $query .= mysql_escape_string($Address_Line_1) . "', '"; $query .= mysql_escape_string($City) . "', '"; $query .= mysql_escape_string($State) . "', '"; $query .= mysql_escape_string($Postal_Code) . "', '"; $query .= mysql_escape_string($Country) . "', '"; $query .= mysql_escape_string($Custom_Field_1) . "', '"; $query .= mysql_escape_string($Custom_Field_2) . "', '"; $query .= mysql_escape_string($Custom_Field_3) . "', '"; if ($Optin) { $query .= "1', '"; // Write a 1 if opted in } else { $query .= "0', '"; // Write a 0 if opted out } $query .= mysql_escape_string($email) . "', '"; // email is a unique field; the same email address will not be written to the table $query .= mysql_escape_string($trial) . "', '"; $query .= mysql_escape_string($parentsite) . "', '"; $query .= mysql_escape_string($today) . "');"; //Execute the Query $result = mysql_query($query) or die(mysql_error()); // Run the query. }








Bookmarks