I think I got it....

What look like what is happening happening is that your page is running the insert 
when you present the form to the user, which is why the php variables are empty.  when 
they submit the page, you are inserting the correct values.  To test this, load the 
page up, do not submit it, and see if you have your empty row.  

If that is the case, then all you need to do is wrap the execution statement in an if 
condition to only process when the form is submitted

> -----Original Message-----
> From: Emilio Ruben Estevez [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 09, 2003 3:39 PM
> To: Dan Greene
> Subject: Re: FW: FW: When inserting data it insert 2 records 
> one correct
> and one blank!
> 
> 
> Im lost, im new on php and mysql so i may be omitting some 
> statements or 
> logics i send you the entire script, its an lbi that i use on 
> DreamWeaber MX 
> if you can just take a look at it. Thanks.
> 
> <meta http-equiv="Content-Type" content="text/html; 
> charset=iso-8859-1">
> 
> <?php
> 
> 
> 
> $db = mysql_connect("localhost", "root");
> 
> mysql_select_db("qllamo",$db);
> 
> 
> 
> 
>     $sql = "INSERT INTO llamadas 
> (destinatario,fecha,hora,apellido,nombre,telefono,mail,recepto
> r,mensaje) 
> VALUES 
> ('$destinatario','$fecha','$hora','$apellido','$nombre','$tele
> fono','$mail','$receptor','$mensaje')";
> 
> $result = mysql_query($sql);
> ?>
>   <form method="post" action="<?php echo $PHP_SELF?>">
>   <input type=hidden name="id" value="<?php echo $id ?>">
>   <table bgcolor="#F2F0E0">
> 
> <tr>
>   <td>Destinatario:</td><td align="center"><input type="Text" 
> name="destinatario" value="<?php echo $destinatario ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Fecha:</td><td align="center"><input type="Text" name="fecha" 
> value="<?php print (date("Y-m-d")) ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Hora:</td><td align="center"><input type="Text" name="hora" 
> value="<?php print (date("h-i-d")) ?>"><br></td>
> </tr>
> 
> <tr>
>   <td align="left">Apellido:</td><td align=center><input type="Text" 
> name="apellido" value="<?php echo $apellido ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Nombre:</td><td align="center"><input type="Text" name="nombre" 
> value="<?php echo $nombre ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Teléfono:</td><td align="center"><input type="Text" 
> name="telefono" 
> value="<?php echo $telefono ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Mail:</td><td align="center"><input type="Text" name="mail" 
> value="<?php echo $mail ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Receptor:</td><td align="center"><input type="Text" 
> name="receptor" 
> value="<?php echo $receptor ?>"><br></td>
> </tr>
> 
> <tr>
>   <td>Mensaje:</td><td align="center"><textarea  
> name="mensaje" cols="70" 
> rows="5" value="<?php echo $mensaje ?>"></textarea><br></td>
> </tr>
> 
> <tr>
> <center> <td> <input name="reset" type="reset" 
> value="Borrar"></td></center>
> <center> <td> <input type="Submit" name="submit" 
> value="Grabar"></td></center>
> </tr>
> </table>
> 
>   </form>
> 
> 
> 
> 
> >From: "Dan Greene" <[EMAIL PROTECTED]>
> >To: "Emilio Ruben Estevez" <[EMAIL PROTECTED]>
> >Subject: FW: FW: When inserting data it insert 2 records one 
> correct and 
> >one blank!
> >Date: Thu, 9 Oct 2003 13:27:45 -0400
> >
> >
> >
> >-----Original Message-----
> >From: Matt Davies [mailto:[EMAIL PROTECTED]
> >Sent: Thursday, October 09, 2003 11:10 AM
> >To: Dan Greene
> >Subject: Re: FW: When inserting data it insert 2 records one 
> correct and
> >one blank!
> >
> >
> >Emilio-
> >I ran into this problem just yesterday using some PHP code. 
> The problem was 
> >in
> >control logic.  I executed the insert within an if 
> statement, but failed to 
> >see
> >that there was another mysql_query statement outside the if 
> block. This 
> >caused
> >the same insert to happen again.
> >
> >Basically, in psuedo code
> >
> >if (found){
> >   query = "INSERT ...."
> >   mysql_query (query)
> >} else {
> >   query = "UPDATE ...."
> >   mysql_query (query)
> >}
> >
> >mysql_query(query)
> >
> >
> >
> >Stupid logic on my part.  This doesn't adress the date being 
> blank, but I 
> >would
> >suggest reviewing your logic to see if there is a 
> mysql_query that is being
> >executed 2 times.
> >
> >My 2 cents...
> 
> _________________________________________________________________
> Instant message in style with MSN Messenger 6.0. Download it 
> now FREE!  
> http://msnmessenger-download.com
> 
> 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to