I have an account class that I have just completed.
It has a function that validates the data of the object, prepares it to go into the database (mysql_real_escape_string()), and returns an array of the cleaned up data.
PROBLEM:
When I try to put it in the database, I get errors, or it inserts nothing.
I have used print_r() to verify that the array actually contains something, and it does. I just can't insert the array into the database! Here is my code, any suggestions?
IF($acct->validate())
{
$cleanData = $acct->dbPrepare();
$time = time();
$query = "INSERT INTO
accounts
(username,password,status,level,firstName,middleInitial,lastName,dateOfBirth,streetAddress,city,state,zip,telephone,email,displayEmail,biography,date_added)
VALUES
('{$cleanData['username']}','{$cleanData['password']}','0','0','{$cleanData['firstName']}','{$cleanData['middleInitial']}','{$cleanData['lastName']}','{$cleanData['dateOfBirth']}','{$cleanData['streetAddress']}','{$cleanData['city']}','{$cleanData['state']}','{$cleanData['zip']}','{$cleanData['telephone']}','{$cleanData['email']}','{$cleanData['displayEmail']}','{$cleanData['biography']}','$time')";
//place object into database
IF(mysql_query($query))
{
$acct->new_account_success();
}
ELSE
{
$acct->new_account_failure();
PRINT("<br>Query is:<br><br>$query<br><br>");
echo mysql_error();
}
}
This is the output I get -
Query is:
INSERT INTO accounts (username,password,status,level,firstName,middleInitial,lastName,dateOfBirth,streetAddress,city,state,zip,telephone,email,displayEmail,biography,date_added) VALUES ('','','0','0','','','','','','','','','','','','','1130224839')