Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/09/2014, 05:39
alfuco
 
Fecha de Ingreso: julio-2014
Mensajes: 53
Antigüedad: 9 años, 9 meses
Puntos: 1
Respuesta: Eliminar mensaje "duplicate entry"

Cita:
Iniciado por alfuco Ver Mensaje
Jajjaj es verdad! Lo que quiero es que despues de introducir datos, estos se guarden en la base de datos y a la vez que se muestren en una tabla por pantalla para poder imprimirlos posteriormente. El problema es que cuando le doy a "introducir datos", estos se guardan en la db y se muesttra la tabla vacia, y cuando hago "return" al navegador y vuelvo a darle "introducir datos" se llena la tabla perfectamente y aparece el mensaje "Error. Duplicate entry". Yo quiero solucionar uno de los dos errores: el de que no se llene la tabla de primeras, o el de que me aparezca el error de segundas... jajaja

Ahora posteo el codigo
Código:
<?php 
error_reporting(0);

$Nombre = $_POST['Nombre'];
$Fecha = $_POST['Fecha'];
$Oferta = $_POST['Oferta'];
$Atencion = $_POST['Atencion'];

if('Lenguasource1' != "Ninguna") {
$LS1 = $_POST['Lenguasource1']; }

if('Lenguasource2' != "Ninguna") {
$LS2 = $_POST['Lenguasource2']; }

if('Lenguasource3' != "Ninguna") {
$LS3 = $_POST['Lenguasource3'];}

if('Lenguatarget1' != "Ninguna") {
$LT1 = $_POST['Lenguatarget1'];}

if('Lenguatarget2' != "Ninguna") {
$LT2 = $_POST['Lenguatarget2'];}

if('Lenguatarget3' != "Ninguna"){
$LT3 = $_POST['Lenguatarget3'];}

.
.
.

$n1=$_POST['Preciopalab'];
$n2=$_POST['PNuevas'];
$n4=$_POST['PCoinc'];
$n6=$_POST['PRepe'];
$preciopal=$_POST['Preciopalab'];

function importenuevas($n1,$n2) {$precionuev=$n1*$n2; 
return $precionuev;}
$precionuev=importenuevas($n1,$n2);
$precionuev=round($precionuev * 100) / 100;


function importecoincidentes($n1,$n4) {$preciocoincid=$n3*$n4*(2/3); 
return $preciocoincid;}
$preciocoincid=importecoincidentes($n3,$n4);
$preciocoincid=round($preciocoincid * 100) / 100;


function importerepetidas($n1,$n6) {$preciorepe=$n5*$n6/3; 
return $preciorepe;}
$preciorepe=importerepetidas($n5,$n6);
$preciorepe=round($preciorepe * 100) / 100;


function total($preciorepe,$preciocoincid,$precionuev) {$preciototal=$preciorepe+$preciocoincid+$precionuev; 
return $preciototal;}
$preciototal=total($preciorepe,$preciocoincid,$precionuev);

$preciototaldecimal=number_format($preciototal, 2, '.', '');  
$preciopaldecimal=number_format($preciopal, 2, '.', '');  

function saltoLinea($str) { 
  return str_replace(array("\r\n", "\r", "\n"), "</br>", $str); 
} 

$Preciodecimal = $_POST['preciopaldecimal'];
$Nombrearchivo = $_POST['Nomarch'];
$Pnuevas = $_POST['PNuevas'];
$Pcoinc = $_POST['PCoinc'];
$Prepe = $_POST['PRepe'];
$preciototaldecimal = $_POST['preciototaldecimal'];
$Terminio = $_POST['Terminio'];
$Otros = $_POST['Otros'];
$Metodoentrega = $_POST['Metodoentrega'];
$Metodopago = $_POST['Metodopago'];
$Datosfact = $_POST['Datosfact'];
$Iva = $_POST['Iva']
?>

<table width="1173" border="1">
  <tr>
    <td colspan="11" bgcolor="#000066" class="Titulo"><span class="sa">Oferta de traducción para</span> <?php echo $Nombre; ?></td>
  </tr>
  <tr>
    <td colspan="2"><strong class="pequeño">Fecha:</strong></td>
    <td width="93" class="datos"><?php echo $Fecha; ?> </td>
    <td colspan="4">&nbsp;</td>
    <td background="../logoredim.jpg"  colspan="4"; rowspan="8">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2"><strong class="pequeño">Oferta nº:</strong></td>
    <td class="datos"><?php echo $Oferta; ?></td>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2"><strong class="pequeño">Atención:</strong></td>
    <td class="datos"><?php echo $Atencion; ?></td>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#000066" class="Titulo2">Datos del contacto</td>
  </tr>
  <tr>
    <td colspan="7" class="pequeño"><strong>Key Account Manager:</strong> Lisard Jiménez</td>
  </tr>
  <tr>
    <td colspan="7" class="pequeño"><strong>Tel.:</strong> +34 93 587 84 07</td>
  </tr>
  <tr>
    <td colspan="7" class="pequeño"><strong>Mobile:</strong> +34 653 417 467</td>
  </tr>
  <tr>
    <td colspan="7" class="pequeño"><strong>Email:</strong> [email protected]</td>
  </tr>
  <tr>
    <td colspan="11" bgcolor="#000066" class="Titulo">Traducción</td>
  </tr>
  <tr>
    <td colspan="3" class="datos"><strong>Lenguas</strong></td>
    <td width="180">&nbsp;</td>
    <td colspan="3" class="datos">Número de palabras</td>
    <td colspan="3" class="datos">Sub-totales</td>
    <td width="71">&nbsp;</td>
  </tr>
  <tr>
    <td width="78" class="datos">Origen</td>
    <td width="78" class="datos">Destinación</td>
    <td width="93" class="datos">Euros/Palabra</td>
    <td class="datos">Nombre del archivo</td>
    <td width="78" class="datos">Nuevas</td>
    <td width="78" class="datos">Coincidencias</td>
    <td width="78" class="datos">Repetidas</td>
    <td width="78" class="datos">Importe total nuevas</td>
    <td width="78" class="datos">Importe total coincidencias</td>
    <td width="78" class="datos">Importe total repetidas</td>
    <td class="datos">Total</td>
  </tr>
  <tr>
    <td class="diferente"><?php if($LS1!= "Ninguna") { echo $LS1;} ?>
    <?php if($LS2 != "Ninguna") { echo $LS2;} ?>
    <?php if($LS3 !="Ninguna") { echo $LS3;} ?></td>
    <td class="diferente"><?php if($LT1 != "Ninguna") { echo $LT1;} ?>
    <?php if($LT2 != "Ninguna") { echo $LT2;} ?>
    <?php if($LT3 != "Ninguna") { echo $LT3;} ?>
    <?php if($LT4 != "Ninguna") { echo $LT4;} ?>
    <?php if($LT5 != "Ninguna") { echo $LT5;} ?>
    <?php if($LT6 != "Ninguna") { echo $LT6;} ?>
    <?php if($LT7 != "Ninguna") { echo $LT7;} ?>
    <?php if($LT8 != "Ninguna") { echo $LT8;} ?>
    <?php if($LT9 != "Ninguna") { echo $LT9;} ?>
    <?php if($LT10 != "Ninguna") { echo $LT10;} ?>
    <?php if($LT11 != "Ninguna") { echo $LT11;} ?>
    <?php if($LT12 != "Ninguna") { echo $LT12;} ?>
    <?php if($LT13 != "Ninguna") { echo $LT13;} ?>
    <?php if($LT14 != "Ninguna") { echo $LT14;} ?>
    <?php if($LT15 != "Ninguna") { echo $LT15;} ?>
    <?php if($LT16 != "Ninguna") { echo $LT16;} ?>
    <?php if($LT17 != "Ninguna") { echo $LT17;} ?>
    <?php if($LT18 != "Ninguna") { echo $LT18;} ?>
    <?php if($LT19 != "Ninguna") { echo $LT19;} ?>
    <?php if($LT20 != "Ninguna") { echo $LT20;} ?>
    <?php if($LT21 != "Ninguna") { echo $LT21;} ?>
    <?php if($LT22 != "Ninguna") { echo $LT22;} ?>
    <?php if($LT23 != "Ninguna") { echo $LT23;} ?>
    <?php if($LT24 != "Ninguna") { echo $LT24;} ?>
    <?php if($LT25 != "Ninguna") { echo $LT25;} ?>
</td>
    <td class="diferente"><?php echo $n1 ?></td>
    <td class="diferente"><?php echo $Nombrearchivo ?></td>
    <td class="diferente"><?php echo $Pnuevas ?></td>
    <td class="diferente"><?php echo $Pcoinc ?></td>
    <td class="diferente"><?php echo $Prepe ?></td>
    <td class="diferente"><?php echo $precionuev ?></td>
    <td class="diferente"><?php echo $preciocoincid ?></td>
    <td class="diferente"><?php echo $preciorepe ?></td>
    <td class="diferente"><?php echo $preciototal ?></td>
  </tr>
  <tr>
    <td colspan="7">&nbsp;</td>
    <td colspan="3" bgcolor="#000066" class="Titulo">Importe total</td>
    <td class="datos"><?php echo $preciototal ?></td>
  </tr>
</table>
<p class="negro">Plazo: <?php echo $Terminio ?> </p>
<p class="negro">Nota: <?php echo $Otros ?></p>
<p class="negro">Forma de entrega: <?php echo $Metodoentrega ?></p>
<p class="negro">Forma de pago: <?php echo $Metodopago ?></p>
<p class="negro">IVA: <?php echo $Iva ?></p>
<p class="negro">Datos de facturación: <?php echo $Datosfact ?></p>
<p class="negro">Signatura i sello:</p>
<p>&nbsp;</p>


<img src="../Applus.jpg" >
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$con=mysqli_connect("localhost","root","SIENSxy5", "SIENS");

if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


$Texto= saltoLinea($_POST['Otros']);  



$sql="INSERT INTO Presupuestos (`Cliente (empresa)`, Fecha, `Numero de oferta`, Atencion, `Lengua source 1`, `Lengua source 2`, `Lengua source 3`,`Lengua target 1`,
`Lengua target 2`,`Lengua target 3`,`Lengua target 4`,`Lengua target 5`,`Lengua target 6`,`Lengua target 7`, `Lengua target 8`,`Lengua target 9`,
`Lengua target 10`,`Lengua target 11`,`Lengua target 12`,`Lengua target 13`,`Lengua target 14`,`Lengua target 15`, `Lengua target 16`,`Lengua target 17`,
`Lengua target 18`,`Lengua target 19`,`Lengua target 20`,`Lengua target 21`,`Lengua target 22`,`Lengua target 23`,`Lengua target 24`,`Lengua target 25`,
`Precio por palabra`, `Nombre del archivo`, `Numero de palabras nuevas`, `Numero de palabras coincidentes`, `Numero de palabras repetidas`,
`Importe total`, `Plazo`, `Forma de pago`, `Forma de entrega`, `IVA`, `Datos de facturacion`, `Nota`)
VALUES
('$_POST[Nombre]','$_POST[Fecha]','$_POST[Oferta]','$_POST[Atencion]','$_POST[Lenguasource1]','$_POST[Lenguasource2]','$_POST[Lenguasource3]',
'$_POST[Lenguatarget1]','$_POST[Lenguatarget2]','$_POST[Lenguatarget3]','$_POST[Lenguatarget4]','$_POST[Lenguatarget5]','$_POST[Lenguatarget6]',
'$_POST[Lenguatarget7]','$_POST[Lenguatarget8]','$_POST[Lenguatarget9]','$_POST[Lenguatarget10]','$_POST[Lenguatarget11]','$_POST[Lenguatarget12]',
'$_POST[Lenguatarget13]','$_POST[Lenguatarget14]','$_POST[Lenguatarget15]','$_POST[Lenguatarget16]','$_POST[Lenguatarget17]','$_POST[Lenguatarget18]',
'$_POST[Lenguatarget19]','$_POST[Lenguatarget20]','$_POST[Lenguatarget21]','$_POST[Lenguatarget22]','$_POST[Lenguatarget23]','$_POST[Lenguatarget24]',
'$_POST[Lenguatarget25]','$preciopaldecimal','$_POST[Nomarch]','$_POST[PNuevas]','$_POST[PCoinc]','$_POST[PRepe]','$preciototal','$_POST[Terminio]',
'$_POST[Metodopago]','$_POST[Metodoentrega]','$_POST[Iva]','$_POST[Datosfact]','$_POST[Otros]')";

if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}

echo "<meta http-equiv='refresh' content='0;URL=http://localhost/SIENS/Presupuestos/Process%20Presupuestos.php'>";

}

?>