You are here: php lost variable 0 from the form when i try to save it into mysql database - please help « PHP Programming Language « IT news, forums, messages
php lost variable 0 from the form when i try to save it into mysql database - please help

Posted by Dominik Szczurek on 02/04/06 16:52

Hello to anyone who is tring to help me :-)

As I was writed in the topic I have problem when somone input 0 value in the
form.
PHP is losting this value when it try to write it to mySQL.
I have php version 4.3.11 mysql 4.1.14 and apache 2.0.53

Please help because I don't know what is wrong.

The column type in database is float. When I try to add some record thru the
phpmyadmin for exapmle, everything is all right.
It is also right when the value is 0.0 but mysql save it as 0

Below is code from php (first the form in html, second sql statement in php)

--html--
<tr class=wiersz_2 valign="center" align="center" >
<td align="right">ZasadowoΆζ typu p :</td>
<td>
<input maxlength="6" size="6" name="zasadowosc_typu_p" tabindex="3">
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
--html--

--php--
if(!empty($_POST['zasadowosc_typu_p'])) $zasadowosc_typu_p_b =
(double)$_POST['zasadowosc_typu_p'];
else
|
$zasadowosc_typu_p_b = -1; (I even try to change
temporary type of this variable)
if(!empty($_POST['twardosc_ogolna_w'])) $twardosc_ogolna_w_b =
$_POST['twardosc_ogolna_w'];
else
$twardosc_ogolna_w_b = -1;
..
..
..
$SQL = "INSERT INTO pomiary (obiekt, nazwa_pomiaru, wartosc, id_datap)";
$SQL .= " (SELECT '{$_SESSION['obiekt_b']}', 'zasadowosc_typu_p',
$zasadowosc_typu_p_b, datap.id";
$SQL .= " FROM datap";
$SQL .= " WHERE datap.id = (SELECT max(datap.id) from datap))";
$ResultSQL = mysql_query($SQL);
$SQL = "INSERT INTO pomiary (obiekt, nazwa_pomiaru, wartosc, id_datap)";
$SQL .= " (SELECT '{$_SESSION['obiekt_b']}', 'twardosc_ogolna_w',
$twardosc_ogolna_w_b, datap.id";
$SQL .= " FROM datap";
$SQL .= " WHERE datap.id = (SELECT max(datap.id) from datap))";
$ResultSQL = mysql_query($SQL);
--php--

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация