Multiple databases

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mpiaser
Forum Newbie
Posts: 12
Joined: Wed Sep 07, 2005 8:16 pm

Multiple databases

Post by mpiaser »

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I'm hoping somebody can save me the pain of struggling through this one.  I'm trying to copy records from one database to another.  I am able to do this in the MySQL Query Browser but my code in PHP (follows) errors.

Code: Select all

$dbc=@mysql_connect('localhost','CalcUser','dog') or die('ChangeAccountName: bad calcuser password: '.mysql_error());
$junk=mysql_select_db('calculator') or die('Could not select database:'.mysql_error());

$query="'insert into archive.account select * from calculator.account where dateadded<'$ArchiveDate' and PolicyNumber=''";
$result=mysql_query($query) or die('Archive:Insert acount: query='.$query.',error='.mysql_error());
The die result is as follows:

Code: Select all

Archive:Insert acount: query='insert into archive.account select * from calculator.account where dateadded<'2006-10-10' and PolicyNumber='',error=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 ''insert into archive.account select * from calculator.account where dateadded<'2' at line 1

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

get rid of the single quote (') at the beginning of your query
mpiaser
Forum Newbie
Posts: 12
Joined: Wed Sep 07, 2005 8:16 pm

Multiple database

Post by mpiaser »

Thanks a tons. I didn't see the darn single quote!
Post Reply