ok so i am having problems if you look at the script below you will
see that it the query has 4 values to insert but the actual values only
contain title entry and now() for the date. well i have made the
database and the blog_id is a primary auto interger what ever table
bascly look below the the insert code block to find the code block
that makes the table in the database,
// Define the query.
$query = "INSERT INTO blog_entries (blog_id, title, entry,
date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}',
NOW())";
// Execute the query.
if (@mysql_query ($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could add the entry because: <b>" . mysql_error() . "</b>.
The query was $query.</p>";
}
---------------------------------------------------------------------------------------------------------------------------------------------------
// Define the query.
$query = 'CREATE TABLE blog_entries (
blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100) NOT NULL,
entry TEXT NOT NULL,
date_entered DATETIME NOT NULL
)';
// Run the query.
if (@mysql_query ($query)) {
print '<p>The table has been created.</p>';
} else {
die ('<p>Could not create the table because: <b>' . mysql_error() .
'</b>.</p><p>The query being run was: ' . $query . '</p>');
}
---------------------------------------------------------------------------------------------------------------------------------------------
>>>>blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<<<<
basicly that right above is what the table looks like now though if i
go and run the insert script it says that the collumns dont match the
values ect. but how can i get it to utilize the blog id table?
what do i enter as a value? 4 1629
so many sites so little time wrote:
ok so i am having problems if you look at the script below you will
see that it the query has 4 values to insert but the actual values only
contain title entry and now() for the date. well i have made the
database and the blog_id is a primary auto interger what ever table
bascly look below the the insert code block to find the code block
that makes the table in the database,
// Define the query.
$query = "INSERT INTO blog_entries (blog_id, title, entry,
date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}',
NOW())";
// Execute the query.
if (@mysql_query ($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could add the entry because: <b>" . mysql_error() . "</b>.
The query was $query.</p>";
}
---------------------------------------------------------------------------------------------------------------------------------------------------
// Define the query.
$query = 'CREATE TABLE blog_entries (
blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100) NOT NULL,
entry TEXT NOT NULL,
date_entered DATETIME NOT NULL
)';
// Run the query.
if (@mysql_query ($query)) {
print '<p>The table has been created.</p>';
} else {
die ('<p>Could not create the table because: <b>' . mysql_error() .
'</b>.</p><p>The query being run was: ' . $query . '</p>');
}
---------------------------------------------------------------------------------------------------------------------------------------------
>>>blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<<<<
basicly that right above is what the table looks like now though if i
go and run the insert script it says that the collumns dont match the
values ect. but how can i get it to utilize the blog id table?
what do i enter as a value?
Since blog_id is an auto_incrementing field, you shouldn't explicitly
refer to it. MySQL will handle it, then you can get the auto created
value. Try this...
$query = "INSERT INTO blog_entries (title, entry, date_entered) VALUES
('{$_POST['title']}', '{$_POST['entry']}', NOW())";
mysql_query($query);
printf("Last inserted record has id %d\n", mysql_insert_id()); http://us3.php.net/mysql_insert_id
> ok so i am having problems if you look at the script below you will
>see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have made the database and the blog_id is a primary auto interger what ever table bascly look below the the insert code block to find the code block that makes the table in the database,
// Define the query. $query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}', NOW())";
// Execute the query. if (@mysql_query ($query)) { print '<p>The blog entry has been added.</p>'; } else { print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; }
---------------------------------------------------------------------------------------------------------------------------------------------------
// Define the query. $query = 'CREATE TABLE blog_entries ( blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(100) NOT NULL, entry TEXT NOT NULL, date_entered DATETIME NOT NULL )';
// Run the query. if (@mysql_query ($query)) { print '<p>The table has been created.</p>'; } else { die ('<p>Could not create the table because: <b>' . mysql_error() . '</b>.</p><p>The query being run was: ' . $query . '</p>'); }
---------------------------------------------------------------------------------------------------------------------------------------------
>>>>>blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<<<<
basicly that right above is what the table looks like now though if i go and run the insert script it says that the collumns dont match the values ect. but how can i get it to utilize the blog id table? what do i enter as a value?
You have three columns and two values in your insert. You need
the number of columns and the number of values to match.
If you leave the blog_id column out of the insert, it will get
filled in with an auto-increment value. This, I think, is what you
want.
If you leave the blog_id column in the insert, and supply null as
a matching value, it will still get filled in with an auto-increment
value. This, I think, is what you want, done another way.
On the other hand, if you leave the blog_id column in the insert,
and supply a number as a matching value, it will insert that value.
Among other things, this lets you restore tables from a backup
without messing up the auto-increment entries.
yeah i think im gonna insert null i just wat to be able to post text so
that it appears like the content of a web page and then can be edited
but when ive been going and trying to edit it say i say home_id 1 or
what ever and then i tell it to get from row 1 it returns a error
which i tell it to if it didnt get an id
Gordon Burditt wrote:
ok so i am having problems if you look at the script below you will
see that it the query has 4 values to insert but the actual values only
contain title entry and now() for the date. well i have made the
database and the blog_id is a primary auto interger what ever table
bascly look below the the insert code block to find the code block
that makes the table in the database,
// Define the query.
$query = "INSERT INTO blog_entries (blog_id, title, entry,
date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}',
NOW())";
// Execute the query.
if (@mysql_query ($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could add the entry because: <b>" . mysql_error() . "</b>.
The query was $query.</p>";
}
---------------------------------------------------------------------------------------------------------------------------------------------------
// Define the query.
$query = 'CREATE TABLE blog_entries (
blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100) NOT NULL,
entry TEXT NOT NULL,
date_entered DATETIME NOT NULL
)';
// Run the query.
if (@mysql_query ($query)) {
print '<p>The table has been created.</p>';
} else {
die ('<p>Could not create the table because: <b>' . mysql_error() .
'</b>.</p><p>The query being run was: ' . $query . '</p>');
}
---------------------------------------------------------------------------------------------------------------------------------------------
>>>>blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<<<<
basicly that right above is what the table looks like now though if i
go and run the insert script it says that the collumns dont match the
values ect. but how can i get it to utilize the blog id table?
what do i enter as a value?
You have three columns and two values in your insert. You need
the number of columns and the number of values to match.
If you leave the blog_id column out of the insert, it will get
filled in with an auto-increment value. This, I think, is what you
want.
If you leave the blog_id column in the insert, and supply null as
a matching value, it will still get filled in with an auto-increment
value. This, I think, is what you want, done another way.
On the other hand, if you leave the blog_id column in the insert,
and supply a number as a matching value, it will insert that value.
Among other things, this lets you restore tables from a backup
without messing up the auto-increment entries.
so many sites so little time schreef:
yeah i think im gonna insert null i just wat to be able to post text so
that it appears like the content of a web page and then can be edited
but when ive been going and trying to edit it say i say home_id 1 or
what ever and then i tell it to get from row 1 it returns a error
which i tell it to if it didnt get an id
>// Define the query.
>$query = 'CREATE TABLE blog_entries (
> blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
> title VARCHAR(100) NOT NULL,
> entry TEXT NOT NULL,
> date_entered DATETIME NOT NULL
> )';
Here you write something like this:
INSERT INTO A_TABLE (Column_1, Column_2, Column_3,
Column_4) VALUES (Value_2, Value_3, Column_4)
as mentioned above it should be like:
INSERT INTO A_TABLE (Column_1, Column_2, Column_3,
Column_4) VALUES (Value_1,Value_2, Value_3, Column_4)
And since Column_1 is an AUTO_INCREMENT-id, u don't need to include it
in your insert at all.
So u can use this:
INSERT INTO A_TABLE (Column_2, Column_3,
Column_4) VALUES (Value_2, Value_3, Column_4)
Greets,
Bart This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve |
last post by:
I've searched throughout the python website and can't find an answer.
My problem:
After getting a BYTEA from a postgres database using Pygresql call:
x = Db.query("SELECT seq FROM sequence \...
|
by: Joseph Macari |
last post by:
I recently installed Office2003 on my computer. I had imported (not linked)
a couple of tables from an Access 2000mdb into an Access 2003mdb. I had
composed various queries and forms with these...
|
by: Joner |
last post by:
Hello,
I'm having trouble with a little programme of mine where I connect to
an access database. It seems to connect fine, and disconnect fine, but
then after it won't reconnect, I get the error...
|
by: zerbie45 |
last post by:
I have a high number of computers that at logon write some information
to a sql 2005 database. Information such as computer name, user name,
logon date and logon time are entered.
Because...
|
by: jeffblk |
last post by:
Hello:
Is there a simple way to track who is entering records into a database?
We have a one table, one form simple database that two people use to assign medical cases. We would like to know which...
|
by: Wayne |
last post by:
I'm experiencing the following intermittent problem with Access 2003
(Access 2000 file format) under Vista. Sometimes when I close a
database by closing the database window I get the following...
|
by: Iyhamid |
last post by:
Hi Every 1
I have a big problem If any 1 can help me....
Here it is
I am working on a access project for customers who have pos (point of sale machines). They do everyday transactions on those...
|
by: dirk |
last post by:
Hey,
I'm new to php and I'm trying to write some php code so that I can
insert data into a mysql database using html forms.
I've got two text forms and a submit button. When entering data and...
|
by: Lawrence Krubner |
last post by:
Do any problems come up when using a static variable in a cron job?
Assuming the cron job is called every 5 minutes for one year. Assume
I've got an array that stores the names of which users are...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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...
| |