473,395 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Performing mail merge from a mySQL database

26
I run a php site which contains a number of user details onto a mySQL database.

I would like to be able to use the user database stored on my site's remote server as a source for mail merge fields in word:mac on my computer - the server connection is through ssl.

So far, I have figured out that I need to do download the tables to Excel first, using a third party ODBC driver (e.g. Actual Technologies). I have got the system to work with my machine as the host, but I am not able to connect to the remote database using ODBC - I suspect this is because I haven't found a way to log onto the server before logging onto the database itself.

Is this task possible, and if so, am I using the right approach?
Sep 1 '07 #1
7 3681
erp23
26
Ok, I've been trying to set up ssh tunneling in order to connect to the remote host through the terminal, but I haven't managed to get the syntax right. It is worth noting that I am running mySQL on my local comp, so will need a different port for this.

I've been using:
Expand|Select|Wrap|Line Numbers
  1. ssh -l user -L 3660:localhost:3660 remoteserver
  2.  
I'm not an expert on port settings, so in desperate need for some advice?

Alternatively, is there a good GUI driven SSH client for Mac?
Sep 1 '07 #2
pbmods
5,821 Expert 4TB
Heya, Erp.

To load your data into Excel, consider exporting your data as a CSV:

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.         *
  3.     FROM
  4.         `table`
  5.     INTO
  6.         OUTFILE
  7.             '/path/to/file.csv'
  8.             FIELDS TERMINATED BY ','
  9.             OPTIONALLY ENCLOSED BY '"'
  10.             LINES TERMINATED BY '\n'
  11.  
Sep 1 '07 #3
erp23
26
when i run the query i am getting:

error 1045: Access denied for user...


How do I get around this? (since it is a remote server, I don't have root access...)
Sep 2 '07 #4
pbmods
5,821 Expert 4TB
Heya, erp.

Check your login credentials and make sure you are sending the correct Username / Password.

You should not need special permissions to save data into a dumpfile. Can you perform a regular SELECT statement against that table with the same login information?
Sep 2 '07 #5
mwasif
802 Expert 512MB
MySQL Manual says The file is created on the server host, so you must have the FILE privilege to use this syntax.
Sep 2 '07 #6
erp23
26
I've by-passed the problem by creating the output and then creating the page with the appropriate headers....

[PHP] $output = "Username,Title,First Name,Surname,Email,Address 1,Address 2,Address 3,City,Region,Country,Postcode,Telephone,Fax";
$output .= "\n";
$result = mysql_query("SELECT * FROM tbl_usrlogin INNER JOIN tbl_userdetails ON tbl_userdetails.userID=tbl_usrlogin.Username");

while($row = mysql_fetch_array($result)) {

$row[position] = str_replace(",","" , $row[position]);

$output .= "$row[Username], $row[repeat for all values] \n";
}

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename =contacts " .
date("Y-m-d").".csv"); ;
print $output;
mysql_free_result($result);
exit; [/PHP]
Sep 3 '07 #7
pbmods
5,821 Expert 4TB
Heya, Erp.

That'll do it.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 3 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Pierre-Luc Soucy | last post by:
Hi, I was working on some merge tables this morning and it worked fine, but after a few unsuccessful table creation requests (I was making some tests), I could not alter or select from a table...
0
by: Johannes B. Ullrich | last post by:
--=-WKgoK98ejo9BZyGYc3N/ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I am having problems with MySQL 4.0.12 on RedHat Advanced Server 2.1 using a dual Xeon with 8...
9
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access...
4
by: pmhaupt2 | last post by:
I developed an Access 2003 program that will allow the user to produce a group of Word letters that merge with data records from an Access database. I created a mail merge Word document and...
3
by: cdelarte | last post by:
I would like to be able to mail merge records from multiple mysql tables using a simple template, preferably via a command line script. MSWord mail merge via ODBC will not work for me as it only...
8
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to...
6
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
0
by: chromis | last post by:
Hi there, I'll be working on a project soon which will involve outputting a list of names and addresses from a database, these will then be used in an MS Word Mail Merge. I need to know how best...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.