By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

filling MySQL table from within PHP

P: n/a
Hello, I don't seem to get the following right.

In the following I try to fill a MySQL table named 'mutation'. The first
element is a date but MySQL sees this as 0000-00-00 instead of the
date 2002-11-01. Other problem is the textstring in
$_POST['verklaring1'], in MySQL this stays empty.

Can anybody help me with these problems, what am I doing wrong ?
<?php
$query = "insert into mutation values (2002-11-01, 1, 4, 1, 4, 10, 330 ,
' $_POST['verklaring1'] ',\N,\N,\N,\N)";
mysql_db_query("projects", $query);
?>

Thanks, Edward

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Edward

The individual items need to be single-quoted. Also, the item,
'$POST['verklaring1']' is staying blank because you have embedded single
quotes. Try this:

$query = "insert into mutation values ('2002-11-01', '1', '4', '1', '4',
'10', '330' ,
'". $_POST['verklaring1']." ',\N,\N,\N,\N)";

Jim

--
Website Managers, LLC
http://www.websitemanagers.net
AOL IM: WebsiteMgrs
ICQ: 54034415
________________________________
"edward hage" <ed**@xs4all.nl> wrote in message
news:3f*********************@news.xs4all.nl...
Hello, I don't seem to get the following right.

In the following I try to fill a MySQL table named 'mutation'. The first
element is a date but MySQL sees this as 0000-00-00 instead of the
date 2002-11-01. Other problem is the textstring in
$_POST['verklaring1'], in MySQL this stays empty.

Can anybody help me with these problems, what am I doing wrong ?
<?php
$query = "insert into mutation values (2002-11-01, 1, 4, 1, 4, 10, 330 ,
' $_POST['verklaring1'] ',\N,\N,\N,\N)";
mysql_db_query("projects", $query);
?>

Thanks, Edward


Jul 17 '05 #2

P: n/a
Hello Edward,

edward hage wrote:
In the following I try to fill a MySQL table named 'mutation'. The first
element is a date but MySQL sees this as 0000-00-00 instead of the
date 2002-11-01. [...]

Perhaps it would be a good idea to store a timestamp insted of a
ready-formated date (time()).
For this purpose you can use a varchar(32) in your database

[...] <?php
$query = "insert into mutation values (2002-11-01, 1, 4, 1, 4, 10, 330 ,
' $_POST['verklaring1'] ',\N,\N,\N,\N)";
Here another good idea would bo to use "insert into mutation (date, bla,
blubb, ...) values (...) instead of the short form you are using up there.
Your problem might be, that you don't use quotes for your data. Your
term should look like this: ... mutation values ('2002-11-01', '1', '4',
....)

[...]
Thanks, Edward


HTH,

Greetings, Till.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.