473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

filling MySQL table from within PHP

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
2 2076
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
3
by: zaphod | last post by:
I want to use MS Accesss as a front end for an existing MySQL database. Since Acceess doesn't have the same data types, eg. ENUM, am I tied to the smaller subset of types supported by Access? I'm...
5
by: phillip.s.powell | last post by:
$sql = "SELECT IF((SHOW TABLES LIKE '$subselectTableName'), count(*), NULL) AS numRows FROM $subselectTableName"; I am trying to write a SQL statement that will tell me if a table exists or not,...
0
by: taras.di | last post by:
I'm trying to understand why MySQL isn't using all parts of the primary key when I add in an OR statement in the query. I have a people database, and a distances database. The people database...
5
by: strawberry | last post by:
In the function below, I'd like to extend the scope of the $table variable such that, once assigned it would become available to other parts of the function. I thought 'global $table;' would solve...
2
by: GarthRodgers | last post by:
Hey all I'm designing an online exam booking system in Access and need to find a way to import table data into Roboform (or some other form filling package) straight from the database. The only...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
6
by: lukasso | last post by:
Hi, this is my code that should produce something like a timetable for a few days with each day divided into 30 minute pieces. It makes query from MySQL and then creates a 2d $array which then is to...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.