save resolution into db

everything works but saving doesn't :(

after posting variables to save.php I echo it:
echo $_POST['width'];
and result is 1280

but if I put this variable into mysql_query:
mysql_query('INSERT INTO statistika (id,aeg,resojavarvid) VALUES (0,NOW(),"'.$_POST['width'].'")');

it saves an empty fielt :( :( :(

and feel free to answer in german ;)
 
Try this:
PHP:
mysql_query("INSERT INTO statistika (id,aeg,resojavarvid) VALUES (0,'".NOW()."','".$_POST['width']."')");

Is NOW() a function you wrote? I can't find it in the PHP manual.
 
NOW() is a MySQL function to get the current time. NOW() works if the field type is DATETIME. And NOW() sets with type DATETIME the time to 000-00-00 00:00:00

But that's not the problem.
The problem is to put the value of $_POST['width'] into database but how? Just echo $_POST['width']; outputs 1280 but if I put it into MySQL query than it doesn't save the value <- WHY?
 
just some handling of ' and " :-)

is a good idea to go over an normal var

$tmp = $_post['width'];

mysql_query("INSERT INTO statistika (id,aeg,resojavarvid) VALUES (0,NOW(),'$tmp')");
 
Zuletzt bearbeitet:
ich würde kein datetime benutzen, benutz nen integer der 11 zeichen lang ist. dann kannst du besser nach der zeit ordnen oder nur bestimmte zeiträume auslesen. mit date() kommst du auch an alle daten ran wie sekunden, minuten, stunden, tage, jahre etc.. zum einfügen machs so...
PHP:
mysql_query("INSERT INTO statistika (id,aeg,resojavarvid) VALUES (0,'".time()."','".$_POST['width']."')");
 
Zurück