close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

exporting doesnt work for one site but does for another

Thread began 5/24/2016 2:34 pm by Christopher West | Last modified 5/25/2016 8:37 pm by Ray Borduin | 1542 views | 4 replies |

Christopher WestCommunity Expert

exporting doesnt work for one site but does for another

Hi I am a little lost. I have a PHP function that writes all email address to an .csv file. This works fine for a latest project I am working on.

However when I duplicate the code to a previous website project it doesn't output any email addres. instead it outputs the actual SQL to the .csv file.

This is what is exactly outputted to the .csv file = SELECT NewsLetterEmail FROM newsletter<BR><BR>

Here is the code:
(I have made sure I uploaded the relevant files etc to the old website).

php:
<?php require_once('../Connections/ecartdb.php'); ?>

<?php 
require_once('../webassist/mysqli/rsobj.php'); ?>
<?php
header
('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=emails.csv');

$output fopen('php://output''w');

$rows = new WA_MySQLi_RS("rows",$ecartdb,0);
$rows->setQuery("SELECT NewsLetterEmail FROM newsletter");
$rows->execute();

while(!
$rows->atEnd()) {
    
$row = array($rows->getColumnVal("NewsLetterEmail"));
    
fputcsv($output$row);

$rows->moveNext();
}
$rows->moveFirst(); //return RS to first record
?>



Why would it work for one website and not another? (Could it be that it works for my new website as I only have 3 email address in the database...and the old website has a few thousand?

Why would the old website output the SQL query (when the new website doesnt do this).

Well done a few tests, its not the size of the table in the database. and doesnt appear to be the database itself.

I wonder if its because (a) I am running it on a server that isnt using the latest PHP version? or (b) the old website was designed before MySQLi webassist server behaviors? However I had sure I uploaded the mysqli server behaviors folder and made sure it was connecting to a mysqli database connection (the file is a standalone php file so the website should have any impact on it.



Any thoughts would be great :)

Chris

Sign in to reply to this post

Ray BorduinWebAssist

I'm wondering if the table or column name is different on the new server. That may be the first part of an error message saying that query is invalid. Please test it on the new server using phpmyadmin to be sure the SQL statement itself isn't wrong.

Sign in to reply to this post
Did this help? Tips are appreciated...

Christopher WestCommunity Expert

Dont worry its been fixed. For some reason (even though I did ammend the connection file) it somehow hadnt saved on the server.



Chris

Sign in to reply to this post

Christopher WestCommunity Expert

ok I got it working, but the SQL is throwing out syntax errors on some of my queries. for example:

$rows->setQuery("SELECT * FROM newsletter WHERE NewsLetterOptIn = 1 AND NewsLetterEmail IN (SELECT OrderBuyerEmail FROM `orders` WHERE OrderCouponCode != "")");

This is the error: Parse error: syntax error, unexpected '")"' (T_CONSTANT_ENCAPSED_STRING) in /homepages/41/d416416140/htdocs/admin/exports/export-voucher-customers.php on line 10

Sign in to reply to this post

Ray BorduinWebAssist

You will have to use single quotes in your query since the string is encapsulated in double quotes.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...