PDA

View Full Version : client side mysql & ???


ohgeewizzz
09-26-2005, 12:47 PM
Hi,
situation is. a user runs an application that when the computer is logged onto the internet, the user is simply taken to a web page to enter their details. i e name address ... and then this data is saved to a mysql database on the site.

now the problem is:
- when the users computer is not logged onto the net. a form is displayed in the brouser that allows the user to enter the same details ie name address ... and save them to a local mysql database for upload latter.
when the user next starts the app. and is connected to the internet and it goes to the site. the user is promted to submit the previously saved data.
the question is - what kind of script should I use for the client side of the app when the computer is not logged onto the net?
how do I detect connection?

any help would be much apreciated.

thanks g

domedia
09-26-2005, 12:57 PM
You're not looking for a website script, but an application that can run on the local machine, that's how I understand your post.

davidj
09-26-2005, 01:00 PM
what you could do is this

name your DB different from your local db

i used this in an application before but there may be a better method


$hostname_temp = "localhost"; // this is your domain to your live server
$database_temp = "LIVEDB"; // this is your live database name
$username_temp = "mylogin";
$password_temp = "mypassword";
$temp = mysql_pconnect($hostname_temp, $username_temp, $password_temp);
mysql_select_db($database_temp, $temp);
if (mysql_errno($temp)=="1049") // 1049 is error code for unfound DB
{

database does not exist so do something;

}else{

database exists so do somthing;
}

davidj
09-26-2005, 01:04 PM
or you could output as XML if the conection is not live

then your live script will run on successful connection


<?php
$filename = '/path/to/myfile.xml'; //or any other filetype you want to parse

if (file_exists($filename)) {

update database

} else {

dont update database


}
?>