尽管有适当的权限和(我认为)语法,PHP代码仍未执行

时间:2014-07-28 22:13:36

标签: php mysql mysqli sqlite

所以我正在研究这个允许上传SQLite数据库并将相关数据同步到MySQL服务器(在localhost下)的PHP脚本。虽然我确实上传了它,但是一旦我继续编写同步代码,脚本根本不会执行(甚至不打印初始回声“下面是我的代码:

 <?php

echo "prueba1";

$registro = '501';

$target = "bufferupload/".$registro.".db";

$DBServer = 'localhost';
$DBUser   = '********';
$DBPass   = '********';
$DBName   = '********';

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
    echo "The file has been uploaded as ".$registro.".db";

    $con = mysqli_connect($DBServer,$DBUser,$DBPass,$DBName);

    if ($db = new SQLite3($target)) {
        if (mysqli_connect_errno())
        {
            echo "Error";
        } else {
            $q = $db->query('SELECT * FROM Ventas');
            if ($q === false) {
                echo "Error";
            } else {

                $tablaventas = array();
                $i=0;

                while($row = $q->fetchArray(SQLITE3_ASSOC)){
                    if(!isset($row['V_ID'])) continue;

                    $tablaventas[$i]['V_ID'] = $row['V_ID'];
                    $tablaventas[$i]['Cajero_ID'] = $row['Cajero_ID'];
                    $tablaventas[$i]['Total'] = $row['Total'];
                    $tablaventas[$i]['Dolares_Recibidos'] = $row['Dolares_recibidos'];
                    $tablaventas[$i]['Pesos_Recibidos'] = $row['Pesos_Recibidos'];
                    $tablaventas[$i]['Vales_Recibidos'] = $row['Vales_Recibidos'];
                    $tablaventas[$i]['Tarjeta_Recibido'] = $row['Tarjeta_Recibido'];
                    $tablaventas[$i]['Cambio_Dolares'] = $row['Cambio_Dolares'];
                    $tablaventas[$i]['Cambio_Pesos'] = $row['Cambio_Pesos'];
                    $tablaventas[$i]['Vale_Emitido'] = $row['Vale_Emitido'];
                    $tablaventas[$i]['Tipo_Cambio'] = $row['Tipo_cambio'];
                    $tablaventas[$i]['time_stamp'] = $row['time_stamp'];

                    $i++;

                }
                $c=0;
                while($c<=$i){
                    if(!isset($tablaventas[$c]['V_ID'])) continue;

                    mysqli_query($con,"INSERT INTO Ventas VALUES (".$tablaventas[$c]['V_ID'].",".$tablaventas[$c]['Cajero_ID'].",".$tablaventas[$c]['Total'].",".$tablaventas[$c]['Pesos_Recibidos'].",".$tablaventas[$c]['Dolares_Recibidos'].",".$tablaventas[$c]['Vales_Recibidos'].",".$tablaventas[$c]['Tarjeta_Recibido'].",".$tablaventas[$c]['Cambio_Pesos'].",".$tablaventas[$c]['Cambio_Dolares'].",".$tablaventas[$c]['Vale_Emitido'].",".$tablaventas[$c]['Tipo_Cambio'].",".$tablaventas[$c]['time_stamp'].");")

                    $c++;

                }
            }
            //$q = @$db->query('SELECT * FROM Ventas_por_Articulos');
            //if ($q === false) {
                //echo "Error";
            //} else {

            //}
            mysqli_close($con);
        }

        $db->close();
    } else {
        echo "Error";
    }
} 
else
{
    echo "Error";
}

echo "Prueba"; ?>

提前感谢任何和所有帮助!

1 个答案:

答案 0 :(得分:0)

您只是错过了;后面的行:

mysqli_query($con,"INSERT INTO Ventas VALUES (".$tablaventas[$c]['V_ID'].",".$tablaventas[$c]['Cajero_ID'].",".$tablaventas[$c]['Total'].",".$tablaventas[$c]['Pesos_Recibidos'].",".$tablaventas[$c]['Dolares_Recibidos'].",".$tablaventas[$c]['Vales_Recibidos'].",".$tablaventas[$c]['Tarjeta_Recibido'].",".$tablaventas[$c]['Cambio_Pesos'].",".$tablaventas[$c]['Cambio_Dolares'].",".$tablaventas[$c]['Vale_Emitido'].",".$tablaventas[$c]['Tipo_Cambio'].",".$tablaventas[$c]['time_stamp'].");")

如果你把

ini_set('display_errors','1');
error_reporting(E_ALL);

<?php之后,您会注意到错误。任何体面的IDE都会立即向您显示此错误。

我也希望你能重新考虑你的代码风格 - 一行超过500个字符 - 这不是一个好主意。