I’m trying to create a PHP which will Query the MySQL database and pull specific information and then covert it to a file. Please excuse the number of fields but it is needed to collect all this data. Currently I have the following:
[php]<?php if(isset($_POST[‘button1’])) {
$q = mysql_query(“SELECT t.name ‘Category’, p.post_title ‘Company’, GROUP_CONCAT(pm.meta_value) ‘Contact’, p.post_content ‘Description’
FROM wp_terms t, wp_term_taxonomy tx, wp_posts p, wp_postmeta pm, wp_term_relationships tr
WHERE pm.post_id = p.ID AND
tr.object_id = p.id AND
p.post_type = ‘wpbdp_listing’ AND
pm.meta_key in (’_wpbdp[fields][54]’,’_wpbdp[fields][1]’,’_wpbdp[fields][10]’,’_wpbdp[fields][23]’,’_wpbdp[fields][22]’,’_wpbdp[fields][25]’,’_wpbdp[fields][6]’,’_wpbdp[fields][24]’,’_wpbdp[fields][26]’,’_wpbdp[fields][5]’,’_wpbdp[fields][53]’,’_wpbdp[fields][33]’,’_wpbdp[fields][34]’,’_wpbdp[fields][35]’,’_wpbdp[fields][36]’,’_wpbdp[fields][37]’,’_wpbdp[fields][38]’,’_wpbdp[fields][39]’,’_wpbdp[fields][40]’,’_wpbdp[fields][41]’,’_wpbdp[fields][42]’,’_wpbdp[fields][43]’,’_wpbdp[fields][44]’,’_wpbdp[fields][45]’,’_wpbdp[fields][46]’,’_wpbdp[fields][21]’,’_wpbdp[fields][16]’,’_wpbdp[fields][18]’,’_wpbdp[fields][2]’,’_wpbdp[fields][19]’,’_wpbdp[fields][20]’,’_wpbdp[fields][9]’,’_wpbdp[fields][4]’,’_wpbdp[fields][15]’,’_wpbdp[fields][27]’,’_wpbdp[fields][28]’,’_wpbdp[fields][8]’,’_wpbdp[fields][50]’,’_wpbdp[fields][49]’,’_wpbdp[fields][51]’,’_wpbdp[fields][52]’,’_wpbdp[fields][56]’,’_wpbdp[fields][29]’,’_wpbdp[fields][31]’,’_wpbdp[fields][55]’) AND
tr.term_taxonomy_id = tx.term_taxonomy_id AND
tx.term_id = t.term_id
GROUP BY pm.post_id order by t.name, pm.meta_key
INTO OUTFILE ‘database.csv’
FIELDS TERMINATED BY ‘,’
ENCLOSED BY '”’
LINES TERMINATED BY ‘\n’")or die(mysql_error());
if($q) {
echo “successful”;
}else {
echo “error”;
}
} ?>[/php]
In the body I have a button with the button1 label on it, which should execute the script. There seems to be an error in the script, but I am not seeing it. The error being reported is: Error while parsing PHP: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING