从脱机更新数据库

时间:2015-06-24 12:53:34

标签: php mysql webserver localhost

我刚刚使用PHP Mysql创建了一个Web应用程序我想在localserver和在线webserver中安装这个系统。但是当不是网络连接时,它存储在本地mysql中并自动更新或同步在线mysql数据。

Kinly帮助我怎么可能......我只是使用它但不工作。

            <form action ='#' method ='post' enctype='multipart/form-data'>
                            <div class="form-group">

                                        <input type='hidden' class="form-control" value='<?php echo $dbname;?>' name='dbname' required>
                            </div>

                            <div class="form-group">
                                        <label>Upload Photograph </label>
                                        <input type="file" name='backup_file'>
                            </div>
                            <input type="submit" class="btn btn-primary" value='Restore' name='submit'>
            </form>


<?php

include_once('conn.php');
// ------------ Upload Process  -------------------------------//
if(isset($_FILES['backup_file']))
{                               
$file = $_FILES ['backup_file'];
$name1 = $file ['name'];
$type = $file ['type'];
$size = $file ['size'];
$tmppath = $file ['tmp_name']; 



if (!is_dir('upload')) 
{
    mkdir('upload');     
}

if( !move_uploaded_file ($tmppath, 'upload/'.$name1))
{
Echo ("Error In File Upload");
}


# UPDATING PROCESS STRAT HERE #

$mysqli = new mysqli('localhost', 'database_user', 'database_password', 'dbname');

if (mysqli_connect_error()) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}

echo 'Success... ' . $mysqli->host_info . "<br />";
echo 'Retrieving dumpfile' . "<br />";

$sql = file_get_contents('upload/'.$name1);
if (!$sql){
    die ('Error opening file');
}

echo 'processing file <br />';

mysqli_multi_query($mysqli,$sql);

echo "<h4> Backup Updated Successfully. </h4>";
echo "<h2> Thanks for Using ..GURU DAKSHINA</h2>";

$mysqli->close();

}
?>

1 个答案:

答案 0 :(得分:0)

ultra-condensed
extra-condensed
condensed
semi-condensed
normal
semi-expanded
expanded
extra-expanded
ultra-expanded
inherit