Thread: combining c php and mysql

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    13

    combining c php and mysql

    I am writing a c program that interacts with a mysql database on the same computer. That is all working fine.

    I also have a website (mostly PHP) which reads a mysql database on the same server. That is all working fine.

    Now for the next step...

    The two mysql databases (remote & local) are meant to be synchronized. In essence, when my application makes a change to my local database I want it to send the same changes to the hosted website (the website will not make it's own changes to the database, only those I request from my application). I cannot communicate directly with the hosted database (hosts server restrictions that cannot be changed), so I must find a way to update the remote database via PHP.

    I was thinking of using Wininet to notify the website that an update (binary file created by application ???) is ready and then have PHP upload the file, parse it and do the appropriate actions to the remote database. Is this the way to go ? or is there a better idea out there ?

    Thank you.

  2. #2
    Banned
    Join Date
    Jan 2009
    Posts
    30
    What makes you so certain that a C forum would be the most effective place to ask a PHP question? Be that as it may, the good news is it may actually be a good place to state your problem! Since you could certainly write a clientside application that does all the transfers in C without needing to install PHP on the remote machine (i.e. have it fetch updates). Now for the bad news, its VERY difficult to sync up two databases without roughly keeping track of all transactions within a given time-frame so the remote machine will know which records to fetch. Again, this can also be done in PHP or C or Java or whatever you want. The trick is just making sure the other machine is not wasting a lot of time trying to determine what data is new and which is old. Simple solution? A time-stamp field!!!! If you do not have one now, add one!

    Then have the remote database search for entries by date. Trust me, its the most painless way to do this.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    13
    I posted here because it actually is a C question, as well as a logic question (which C programmers are notoriously logical, I know from experience). Personally, I know C, PHP & MySQL quite well and made the decision on which forum to post on carefully. I have been researching this for a while but am just now humbly asking for input from the community.

    That aside. I do not require a timestamp because there is only one application in control of updates (the C program on my local computer). I guess to clarify my question a bit, would it be better for the control application (again, written in C) to generate binary update files to send to the website or is there a known communication platform between C and PHP so the two can "chat" (client/server) ? or rather, better to send in bulk or piece by piece ?

    For reference, the application is for a rental company. The control application is for transactions on the client side, the website is to display inventory. Updates would include: Add new inventory item (including jpeg image), Update quantity available. Each database transaction is rather small, especially updating quantity (1 field) which seems like a good place for a simple POST variable passed to the website with Wininet, but adding a new inventory item is 12 fields plus the image.

    Is Wininet the way to go ? or is there something I am missing ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Installing MySQL
    By cerin in forum Tech Board
    Replies: 2
    Last Post: 02-18-2006, 12:30 PM
  2. I need a free host with mysql and php. don't flame me.
    By Xterria in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 05-08-2004, 06:31 PM
  3. PHP & MySQL
    By Jperensky in forum Tech Board
    Replies: 2
    Last Post: 04-21-2004, 09:43 AM
  4. php mysql cprogramming posting issue
    By xddxogm3 in forum Tech Board
    Replies: 5
    Last Post: 03-22-2004, 03:32 PM
  5. php script question (is this possible?)
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 12-30-2003, 09:20 PM