Re: Code dilema --> '".NULL."' or '.NULL.' or ...
| From: | Jason Wong | Date: | Mon, 03 Jun 2002 05:03:03 +0000 |
| Subject: | Re: Code dilema --> '".NULL."' or '.NULL.' or ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-100369@lists.php.net to get a copy of this message | ||
On Thursday 01 January 1970 08:00, Ricardo Fitzgerald wrote:
Your clock is broken!
> I'm having troubles 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.
> Then this is a portion of the php script.
>
> // Add together proper fields to enter birth date
> $fecha_nac = $ano_nac + "-" + $mes_nac + "-" + $dia_nac;
>
> // Open mysql db
> mysql_select_db("intertur");
>
> // 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."'
> )";
> ----> My problem is NOTHING gets inserted !!!
> ----> I filled all empty fields with NULL values
> ----> It connects to the db but does nothing else
MySQL has it's own NULL, you should probably be using that rather than PHP's.
> // Do query
> $result = mysql_query($query);
Do some error checking -- how would you know what's going on if you don't
check!?!
1) echo $query; // to check that it looks OK
2) $result = mysql_query($query) or die(mysql_error()); // to display any
errors
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Bennett's Laws of Horticulture:
(1) Houses are for people to live in.
(2) Gardens are for plants to live in.
(3) There is no such thing as a houseplant.
*/