Can anyone see a problem with this code?
Code: Select all
// delete current temp version
@unlink(TMP_DIR."members.csv");
// construct sql
$sql = "SELECT 'Surname',
'First Name',
'Email',
'Registration Date',
'Opt-In'
UNION
(SELECT user_surname,
user_firstname,
user_email,
DATE_FORMAT(FROM_UNIXTIME(user_registrationdate), '%d/%m/%Y'),
IF (user_optin>0, 'Yes', 'No')
INTO OUTFILE '".TMP_DIR."members.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
FROM user
WHERE role_id=1
ORDER BY user_surname ASC,
user_firstname ASC,
user_registrationdate DESC
) ";
// perform query
$result = mysql_query($sql) or die(mysql_error());the error is sounding like the closing bracket is unexpected but it looks like it should be there to me.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 20
Cheers