Re: storing php pages with sql queries in a mysql database

2005-07-25 Thread Lamont R. Peterson
On Saturday 23 July 2005 09:05am, Gregory Machin wrote:
 Hi all.
 I'm writing a php script to store the contents of html and php pages
 in a data base, it works well until there are mysql queries in the
 pages source then give errors such as this one.

 Query failed: You have an error in your SQL syntax near 'temp'

 how do stop mysql from trying to interperate this data and blindly store it
 ??

Another solution would be to base64 encode the data before storing it in the 
database.
-- 
Lamont R. Peterson [EMAIL PROTECTED]
Founder [ http://blog.openbrainstem.net/peregrine/ ]
OpenBrainstem - Intelligent Open Source Software Engineering


pgpgxxCSkArq0.pgp
Description: PGP signature


Re: Regex problem..

2005-07-25 Thread Lamont R. Peterson
On Monday 25 July 2005 01:56pm, Michael Stassen wrote:
 Gregory Machin wrote:
  Hi.
 
  Please could you advise me...
  I have php pages that are stored in a mysql database, that will later
  be imported into a cms
  I want to use mysql's regex funtion to remove unwanted php code and
  update links to images
  and urls.
 
  But i cant seem to get my brian around the regex part ...
 
  i want to remove the header include ?php require(./include/header1);?
  i tried \?php[^][header1].*\? , and other attempts but no luck ..
  unfortunetly i can do a normal string replace because of varations,in
  the code ...

This regex would not match your case.  Try this on for size:

\?php.*require.*header1.*\?

  Many Thanks

 MySQL's REGEX is only for matching, not for replacement.  If you really
 need a regex search and replace, you may find it easier to dump your data,
 edit it, and reimport it.  If you are determined to do it in mysql, you'll
 need a (probably ugly) combination of mysql string functions.  See the
 manual for details:

 http://dev.mysql.com/doc/mysql/en/string-functions.html
 http://dev.mysql.com/doc/mysql/en/string-comparison-functions.html

As Michael suggests, better to do this in an app.  It should not take you very 
long to write a quick data importer in PHP that would take care of all this 
including using preg_replace () where you want it.
-- 
Lamont R. Peterson [EMAIL PROTECTED]
Founder [ http://blog.openbrainstem.net/peregrine/ ]
OpenBrainstem - Intelligent Open Source Software Engineering


pgpzhFjg8ymNz.pgp
Description: PGP signature


Re: copying rows from one MySQL server to another

2005-07-20 Thread Lamont R. Peterson
On Wednesday 20 July 2005 10:06am, Les Schaffer wrote:
 I am working on a MySQL application where laptops will be collecting
 data into local MySQL tables, and then once a week they will be
 network-connected to a central server where they will check in their
 new data and check out new assignments for data collection.

 given a set of rows in a set of tables on the laptop, is there any nifty
 way of grabbing their data and inserting/updating these rows into the
 server database, other than to do a SELECT on the local connection and
 then turn around and create an INSERT or UPDATE SQL command on the
 remote connection with the same data to push data onto server? same for
 remote-to-laptop.

 due to the nature of the application, laptops will be working on only a
 fraction of the total records on the server, so i can not simply copy
 the tables on server onto laptop, nor can i copy tables from laptop onto
 server, since other laptops will be checking in data too into the same
 tables.

If it were me, I would look at building it as a client/server app.  Build a 
simple server piece that laptop clients connect to, which handles the 
syncranization of the data.

I have built a few like this in the past (working on another now) and it works 
great.

Basically, all you have to do is track which records have not been synced each 
way and then have the client  server do it when they connect.
-- 
Lamont R. Peterson [EMAIL PROTECTED]
Founder [ http://blog.openbrainstem.net/peregrine/ ]
OpenBrainstem - Intelligent Open Source Software Engineering


pgpoFsENH2UJL.pgp
Description: PGP signature