exec("/var/mysql/bin/mysqldump -c -t trade house>/www/root/house.sql");

解决方案 »

  1.   

    SQL 语句 :  exec("/var/mysql/bin/mysqldump -c -t trade house>/www/root/house.sql"
    ) MySQL 返回:
    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 'exec("/var/mysql/bin/mysqldump -c -t trade house>/www/root/house.sql")' at line 1
    返回
      

  2.   

    服务商上面是不允许exec操作的?
      

  3.   

    这个不是sql语句
    是mysql的一个工具程序
      

  4.   

    我想知道sql语句怎么写,
    导出:使用完整添增指令的语句,insert into house() values()这类的!
      

  5.   

    /************************************************
    导出数据结构
    ************************************************/
    function dump_table_stru($table_name)    {
        $db=connect();
        $sqltext="show create table `$table_name`";
        $db->query($sqltext);
        $db->next_record();
        $r=$db->Record['Create Table'];
        $result_temp= "
    # 建立表 $table_name
    $r;";
        return $result_temp;
    }
    /************************************************
    导出数据记录
    ************************************************/
    function dump_table_record($table_name,$where="")    {
        $db=connect();
        $sqltext="select * from $table_name $where";
        $db->query($sqltext);
        $count=$db->num_rows();
        $stru=get_table_stru($table_name);
        $result_temp.="
    # $table_name $count rows";
        while($db->next_record()){
            $r=$db->Record;
            $temp=array();
            for($i=0;$i<$stru['num_fields'];$i++){
                $temp[count($temp)]="'".AddSlashes($r[$i])."'";
            }
            $result_temp.= "
    INSERT INTO `$table_name` VALUES (".implode(",",$temp).");";
        }
        return $result_temp;
    }/************************************************
    主代码部分
    ************************************************/
    //以SQL代码方式备份,备份内容存入TXT格式文件
    $header="####################################################################################
    #<a href="http://www...xxx.cn" target="_blank">www...xxx.cn</a>
    #数据备份
    ####################################################################################
    #备份时间 : ".date('Y.m.d H:i:s')."";
    $time=date('Ymd');
    $file_name="nortar_db_$time.sql";
    global $dump_path,$dump;
    $fp=fopen("$dump_path$file_name",w);
    if(!$fp)    {
        error("备份目录:".$dump_path."权限错误!","java script:history.go(-1)");
    }
    fwrite($fp,$header);
    //取得$site内数据表列表
    global $db;
    $sqltext="show tables from $site";
    $db->query($sqltext);
    while ($db->next_record())    {
        $table_name=$db->Record[0];
        $result=dump_table_stru($table_name);
        fwrite($fp,$result);
        $result=dump_table_record($table_name);
        fwrite($fp,$result);
    }
    fclose($fp);
    show_ok("备份成功,点击链接下载:<a href='$dump$file_name'>$file_name</a>","java script:history.go(-1)");/* 以复制文件方式进行备份,备份文件存入ZIP文件内
    include_once "zip.lib.php";
    $path="E:mysqldatashop";
    $z=new Zip;
    //取目录中文件
    $h=opendir($path);
    while ($f=readdir($h))    {
        if ($f=="." || $f=="..") continue;
        if (is_dir("$path/$f")) continue;
        //取文件内容
        $fd = fopen("$path/$f", "r" );
        $text = fread($fd, filesize("$path/$f"));
        //zip
        $z->Add(Array(Array($f,$text)),0);
    }
    $file_name="DB_shop_".date("Ymd").".zip";
    $full_file_name=$root_path."upload/".$file_name;
    fputs(fopen($full_file_name,"wb"), $z->get_file());
    */
    结帖了!