470,594 Members | 1,318 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

Need help setting up data entry pages. Please help with code.

I am trying to set up a PHP web page so I can enter data into a
database.

I created a form:
<form action="admin_news_insert_processor.php" method="post"
name="frm_Insert_News" id="frm_Insert_News">
Here's the insert query. This code is on the page
admin_news_insert_processor.php:
<?php
$query_rs_inst_news = "INSERT INTO News (ID, Headline, Opener, Story,
Imageloc, Anchor, Artist_ID) VALUES
('".$_POST['News_Headline']."','".$_POST['News_Opener']."','".$_POST['News_Story']."','".$_POST['News_Image_Loc']."','".$_POST['News_Anchor']."','".$_POST['News_Artist']."');";
$rs_inst_news = mysql_query($query_rs_inst_news);

I don't know if this query is written correctly. Should
'".$_POST[this]."' be the names of the form fields on the form from
the first page?

Is the rest of the query written correctly?

Help me please!!!!
Jul 17 '05 #1
9 2317
Don Seckler wrote:
I am trying to set up a PHP web page so I can enter data into a
database.

I created a form:
<form action="admin_news_insert_processor.php" method="post"
name="frm_Insert_News" id="frm_Insert_News">
Here's the insert query. This code is on the page
admin_news_insert_processor.php:
<?php
$query_rs_inst_news = "INSERT INTO News (ID, Headline, Opener, Story,
Imageloc, Anchor, Artist_ID) VALUES
('".$_POST['News_Headline']."','".$_POST['News_Opener']."','".$_POST['News_Story']."','".$_POST['News_Image_Loc']."','".$_POST['News_Anchor']."','".$_POST['News_Artist']."');";
$rs_inst_news = mysql_query($query_rs_inst_news);

I don't know if this query is written correctly. Should
'".$_POST[this]."' be the names of the form fields on the form from
the first page?

Is the rest of the query written correctly?

Help me please!!!!


you are missing 'ID' in the values clause. if this is an "auto-increment" field
then it should not appear in the (fields,,,,,) part of the INSERT statement.
You have 7 fields listed and only 6 "values".

$query_rs_inst_news =
"INSERT INTO News (
Headline,
Opener,
Story,
Imageloc,
Anchor,
Artist_ID)
VALUES
('".$_POST['News_Headline'].
"','" . $_POST['News_Opener'] .
"','" . $_POST['News_Story'].
"','" . $_POST['News_Image_Loc'].
"','" . $_POST['News_Anchor'].
"','" . $_POST['News_Artist'].
"');";
$rs_inst_news = mysql_query($query_rs_inst_news);

//*** ID, removed assuming it is an autoincrement field.
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #2
Thanks for the response Michael.

Yes the ID is an auto increment.

Should the bit that comes after POST in the brackets be the names of
the fields form the data entry form?
Michael Austin <ma*****@firstdbasource.com> wrote in message news:<y4****************@newssvr24.news.prodigy.co m>...
Don Seckler wrote:
I am trying to set up a PHP web page so I can enter data into a
database.

I created a form:
<form action="admin_news_insert_processor.php" method="post"
name="frm_Insert_News" id="frm_Insert_News">
Here's the insert query. This code is on the page
admin_news_insert_processor.php:
<?php
$query_rs_inst_news = "INSERT INTO News (ID, Headline, Opener, Story,
Imageloc, Anchor, Artist_ID) VALUES
('".$_POST['News_Headline']."','".$_POST['News_Opener']."','".$_POST['News_Story']."','".$_POST['News_Image_Loc']."','".$_POST['News_Anchor']."','".$_POST['News_Artist']."');";
$rs_inst_news = mysql_query($query_rs_inst_news);

I don't know if this query is written correctly. Should
'".$_POST[this]."' be the names of the form fields on the form from
the first page?

Is the rest of the query written correctly?

Help me please!!!!


you are missing 'ID' in the values clause. if this is an "auto-increment" field
then it should not appear in the (fields,,,,,) part of the INSERT statement.
You have 7 fields listed and only 6 "values".

$query_rs_inst_news =
"INSERT INTO News (
Headline,
Opener,
Story,
Imageloc,
Anchor,
Artist_ID)
VALUES
('".$_POST['News_Headline'].
"','" . $_POST['News_Opener'] .
"','" . $_POST['News_Story'].
"','" . $_POST['News_Image_Loc'].
"','" . $_POST['News_Anchor'].
"','" . $_POST['News_Artist'].
"');";
$rs_inst_news = mysql_query($query_rs_inst_news);

//*** ID, removed assuming it is an autoincrement field.

Jul 17 '05 #3
1)Everything from the data entry form is going into the db (Thanks to
Michael), except for the data from the News_Image form field into the
ImageLoc db field. I can't figure out why?

2)My Header statement isn't redirecting the browser page. I don't
know why.
<?php
$query_artists = "SELECT * From Artists ORDER BY Artist";
$artists = mysql_query($query_artists);
$row_artists = mysql_fetch_assoc($artists);
?>

<?php
$query_rs_inst_news = "INSERT INTO News (Headline, Opener, Story,
ImageLoc, Anchor, Artist_ID) VALUES
('".$_POST['News_Headline']."','".$_POST['News_Opener']."','".$_POST['News_Story']."','".$_POST['News_Image']."','".$_POST['News_Anchor']."','".$_POST['News_Artist']."');";
$rs_inst_news = mysql_query($query_rs_inst_news);
?>
<?php
Header ("Location: http://www.yeahthatrocks.com/master.php");
?>
dj*******@hotmail.com (Don Seckler) wrote in message news:<fe**************************@posting.google. com>...
Thanks for the response Michael.

Yes the ID is an auto increment.

Should the bit that comes after POST in the brackets be the names of
the fields form the data entry form?
Michael Austin <ma*****@firstdbasource.com> wrote in message news:<y4****************@newssvr24.news.prodigy.co m>...
Don Seckler wrote:
I am trying to set up a PHP web page so I can enter data into a
database.

I created a form:
<form action="admin_news_insert_processor.php" method="post"
name="frm_Insert_News" id="frm_Insert_News">
Here's the insert query. This code is on the page
admin_news_insert_processor.php:
<?php
$query_rs_inst_news = "INSERT INTO News (ID, Headline, Opener, Story,
Imageloc, Anchor, Artist_ID) VALUES
('".$_POST['News_Headline']."','".$_POST['News_Opener']."','".$_POST['News_Story']."','".$_POST['News_Image_Loc']."','".$_POST['News_Anchor']."','".$_POST['News_Artist']."');";
$rs_inst_news = mysql_query($query_rs_inst_news);

I don't know if this query is written correctly. Should
'".$_POST[this]."' be the names of the form fields on the form from
the first page?

Is the rest of the query written correctly?

Help me please!!!!


you are missing 'ID' in the values clause. if this is an "auto-increment" field
then it should not appear in the (fields,,,,,) part of the INSERT statement.
You have 7 fields listed and only 6 "values".

$query_rs_inst_news =
"INSERT INTO News (
Headline,
Opener,
Story,
Imageloc,
Anchor,
Artist_ID)
VALUES
('".$_POST['News_Headline'].
"','" . $_POST['News_Opener'] .
"','" . $_POST['News_Story'].
"','" . $_POST['News_Image_Loc'].
"','" . $_POST['News_Anchor'].
"','" . $_POST['News_Artist'].
"');";
$rs_inst_news = mysql_query($query_rs_inst_news);

//*** ID, removed assuming it is an autoincrement field.

Jul 17 '05 #4
I noticed that Message-ID:
<fe*************************@posting.google.com> from Don Seckler
contained the following:
1)Everything from the data entry form is going into the db (Thanks to
Michael), except for the data from the News_Image form field into the
ImageLoc db field. I can't figure out why?
Perhaps it should be $_POST['News_Image_Loc'] ?
2)My Header statement isn't redirecting the browser page. I don't
know why.


Try a lower case 'h'

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5
> >1)Everything from the data entry form is going into the db (Thanks to
Michael), except for the data from the News_Image form field into the
ImageLoc db field. I can't figure out why?


Perhaps it should be $_POST['News_Image_Loc'] ?


I had used News_Image_Loc before and that wasn't working, so I changed
the name of the data entry form text field to News_Image in hope that
maybe that would work...

2)My Header statement isn't redirecting the browser page. I don't
know why.


Try a lower case 'h'


I had a lower case "H" previuosly, and taht wasn't working so I tried
upper.

But thanks for the suggestions.
Jul 17 '05 #6
I noticed that Message-ID:
<fe**************************@posting.google.com > from Don Seckler
contained the following:
Perhaps it should be $_POST['News_Image_Loc'] ?
I had used News_Image_Loc before and that wasn't working, so I changed
the name of the data entry form text field to News_Image in hope that
maybe that would work...


Call it 'x' - no chance of mistyping that..LOL. Personally, I stick to
lowercase only - less chance of mistakes. This is just a textfield
right? You're not using an image field and browsing for a picture or
anything daft like that?
>
>2)My Header statement isn't redirecting the browser page. I don't
>know why.
Try a lower case 'h'


I had a lower case "H" previuosly, and taht wasn't working so I tried
upper.


Is there anything after it? Try putting exit; after the header
function.

Are you getting an error message? Try removing any white space, like
between the php tags.
But thanks for the suggestions.


NP

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #7
> >I had used News_Image_Loc before and that wasn't working, so I changed
the name of the data entry form text field to News_Image in hope that
maybe that would work...
Call it 'x' - no chance of mistyping that..LOL. Personally, I stick to
lowercase only - less chance of mistakes. This is just a textfield
right? You're not using an image field and browsing for a picture or
anything daft like that?


It's a text field. I'm trying to post a URL that will point to the
image. Is that daft? lol I don't know I'm a complete newbie.

>
>2)My Header statement isn't redirecting the browser page. I don't
>know why.

Try a lower case 'h'


I had a lower case "H" previuosly, and taht wasn't working so I tried
upper.


Is there anything after it? Try putting exit; after the header
function.

I'll have to check.

Are you getting an error message? Try removing any white space, like
between the php tags.


No error, just sticking on the processing page.
Jul 17 '05 #8
I noticed that Message-ID:
<fe**************************@posting.google.com > from Don Seckler
contained the following:
right? You're not using an image field and browsing for a picture or
anything daft like that?
It's a text field. I'm trying to post a URL that will point to the
image. Is that daft? lol I don't know I'm a complete newbie.


No that's fine.

Are you getting an error message? Try removing any white space, like
between the php tags.
>


No error, just sticking on the processing page.


I think we'll have to see all the code, from both pages.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #9
Geoff,

Thanks for your help.

I took out all the white space and added the exit() and now the field
fills inproperly and the redirect works perfectly.

I don't understand how tose changes affected that problem field, but
hey it works!

Geoff Berrow <bl******@ckdog.co.uk> wrote in message news:<6k********************************@4ax.com>. ..
I noticed that Message-ID:
<fe**************************@posting.google.com > from Don Seckler
contained the following:
right? You're not using an image field and browsing for a picture or
anything daft like that?


It's a text field. I'm trying to post a URL that will point to the
image. Is that daft? lol I don't know I'm a complete newbie.


No that's fine.

Are you getting an error message? Try removing any white space, like
between the php tags.
>


No error, just sticking on the processing page.


I think we'll have to see all the code, from both pages.

Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mike | last post: by
7 posts views Thread by Kesavan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.