On Wed, 1969-12-31 at 21:59, Ricardo Fitzgerald wrote:
> Hi,
> 
> I'm having trouble trying to insert form data into a mysql db, the
> thing is my client wants table data to be splitted, I mean some data 
> comes from the first form, and the rest from another form.

  Hi Ricardo!

  Why not use a session to store the query data until it is needed for
  your insert? For more information on sessions and PHP, visit
  http://php.net/session

  Also, here are a few tips:
...

> // SQL query insert all data into a table
> $query = "insert into RegistroPersonas values
>                 ('".NULL."','".$nombre."', '".$apellido."', '".NULL."', 
>'".$direccion."', 
> '".$ciudad."', '".NULL."',   '".NULL."', '".$pais."', '".$telefono."', 
> '".$fax."', '".$email."', '".$login_usuario."', '".$clave."', 
> '".$fecha_nac."',  '".NULL."',  '".NULL."' '".$sexo."',  '".NULL."',  
> '".NULL."', '".NULL."', '".NULL."' )";

  You can specify the column names for an insert - you (likely) do 
  not need to use an explicit NULL! (Also, the NULL used in MySQL is
  not the same value as the NULL used in PHP. NULL in PHP evaluates to
  an empty string when used in a string context.)

  You can also use a simpler style of quoting to make your query easier
  to read.

  For example:

  $query = "INSERT INTO RegistroPersonas 
            column_one, column_four, column_seven, column_eight
            VALUES (1, 'FOUR', "$enter-$some-$variables", 8)";
          

> ----> My problem is NOTHING gets inserted !!! 
> ----> I filled all empty fields with NULL values
> ----> It connects to the db but does nothing else
> // Do query  
> $result = mysql_query($query);
> 
> // this script has a form at the end, where the remaining fields are
> // filled
> // and calls the next script, where the tables are altered
> // there and the empty fields filled with the values retrieved
> 
> I suppose to use Update in the next script , to enter remaining
> data, but I'm not sure because the first field auto increments, 
> and is the primary key. 

  Use mysql_insert_id() in PHP to find the number of the last generated
  auto increment.

  Good Luck!
-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Zak Greant <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Advocate
/_/  /_/\_, /___/\___\_\___/   Calgary, Canada
       <___/   www.mysql.com




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to