2016-03-28 66 views
-2

here is the html code我有一個問題,通過我的PHP代碼插入到我的databese,這是我所:我在PHP中插入不工作

//Here is where I make my connection 
$dbhost = 'localhost'; 
$username = 'root'; 
$password = ''; 
$db = 'rafe_test'; 

我這裏測試我的連接:

$conn = mysqli_connect("$dbhost", "$username", "$password","$db") or die ("no se conecto"); 

if(!mysqli_select_db($conn,$db)) 
{ 
    echo'database not selected'; 
} 

// here is where i initialize my vars 


$id_Folio = isset($_POST['idfolio']) ? $_POST['idfolio'] : ''; 
$fecha_Folio = isset($_POST['fechafolio']) ? $_POST['fechafolio'] : ''; 
$n_Maquinas = isset($_POST['nmaquinas']) ? $_POST['nmaquinas'] : ''; 
$desc_Pedido = isset($_POST['descpedido']) ? $_POST['descpedido'] : ''; 

$servicio1 = isset($_POST['servicio[]']) ? $_POST['servicio[]'] : ''; 
$servicio2 = isset($_POST['servicio[]']) ? $_POST['servicio[]'] : ''; 
$servicio3 = isset($_POST['servicio[]']) ? $_POST['servicio[]'] : ''; 
$servicio4 = isset($_POST['servicio[]']) ? $_POST['servicio[]'] : ''; 
$fechaDeFinalizacion = isset($_POST['fechadefinalizacion']) ? $_POST['fechadefinalizacion'] : ''; 
$logisticaDesc = isset($_POST['logisticadesc']) ? $_POST['logisticadesc'] : ''; 

$envio1 = isset($_POST['envio[]']) ? $_POST['envio[]'] : ''; 
$fechaEntregaReporte = isset($_POST['fechadeEntregaReporte']) ? $_POST['fechadeEntregaReporte'] : ''; 
$envio2 = isset($_POST['descripcionServicio']) ? $_POST['descripcionServicio'] : ''; 

這裏是我認爲我有問題的地方,因爲我的小警戒在那裏:

$sql = "INSERT INTO reportes (idFolio, fechaFolio, nMaquinas, descPedido, tareaLogistica1 
,tareaLogistica2,tareaLogistica3,tareaLogistica4,tareaLogistica5Date,descLogistica,tareaServicio1, 
tareaServicio2Date,descripcionServicio) VALUE 
    ('$id_Folio','$fecha_Folio','$n_Maquinas','$desc_Pedido','$servicio1','$servicio2', '$servicio3','$servicio4','$fechaDeFinalizacion','$logisticaDesc','$envio1' ,'$fechaEntregaReporte' ,'$envio2')"; 

if(!mysqli_query($conn,$sql)) 
{ 
    echo'not inserted'; 
} 
else 
{   
    echo'inserted'; 
} 
+0

VALUES而不是VALUE – DevMan

+3

@DevMan在2天內第二次人們說這一點。在MySQL中,兩者都是有效的http://dev.mysql.com/doc/refman/5.7/en/insert.html'INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION(partition_name,...)] [(col_name,...)] {VALUES | VALUE} - 所以請放棄那種誤解。 –

+0

你得到的錯誤是什麼? – webeno

回答

0

你有wr ong關鍵字。它是VALUES

+2

在MySQL中,兩者都是有效的http://dev.mysql.com/doc/refman/5.7/en/insert.html'INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION(partition_name,...)] [(col_name,...)] {VALUES | VALUE}' - Whover以及爲什麼你們這麼做是超出了我的。 –