$wpdb
-
I am converting sql statements to $wpdb methods and getting the same error in different contexts, Fatal error on Call to a member function show_errors() on null in /home4/hsysgrpc/public_html/wp-content/themes/twentytwelve-child/DownloadCommitteesFile. If I comment out show_errors it fails at get_results, so I am missing something basic. I have a page that displays data that attempts to download the data into a csv file. The code for the download file is:
<?php //DownloadCommitteesFile.php 3/17/2022 global $wpdb; $wpdb->show_errors(true); include 'myFuncs.php' ; $link = connect() ; if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error());} header('Content-Type: text/csv'); $FileName = 'Content-Disposition: attachment; filename="'. 'Committees.csv"'; header($FileName); $SQL = "SELECT FirstName, LastName, AAUWDatabase, DiversityInclusion, InternationalRelations, Membership, ProgramPlanning, PublicPolicy, Website, Zoom FROM AAUW_Members WHERE (((AAUWDatabase)=1)) OR (((DiversityInclusion)=1)) OR (((InternationalRelations)=1)) OR (((Membership)=1)) OR (((ProgramPlanning)=1)) OR (((PublicPolicy)=1)) OR (((Website)=1)) OR (((Zoom)=1)) ORDER BY Lastname "; $result = $wpdb->get_results($SQL, ARRAY_A ); $output = fopen('php://output', 'w'); // Download file header record fputcsv($output, array( 'FirstName', 'LastName', 'AAUWDatabase', 'DiversityInclusion', 'InternationalRelations', 'Membership', 'ProgramPlanning', 'PublicPolicy', 'Website', 'Zoom', )); foreach($result as $row){ fputcsv($output, array( $row['FirstName'], $row['LastName'], $row['AAUWDatabase'], $row['DiversityInclusion'], $row['InternationalRelations'], $row['Membership'], $row['ProgramPlanning'], $row['PublicPolicy'], $row['Website'], $row['Zoom'], )); } //end foreach fclose($output); ?>
The page I need help with: [log in to see the link]
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘$wpdb’ is closed to new replies.