Connecting Tech Pros Worldwide Help | Site Map

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

Don Seckler
Guest
 
Posts: n/a
#1: Jul 17 '05
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!!!!
Michael Austin
Guest
 
Posts: n/a
#2: Jul 17 '05

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


Don Seckler wrote:[color=blue]
> 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!!!![/color]

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
:)
Don Seckler
Guest
 
Posts: n/a
#3: Jul 17 '05

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


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 <maustin@firstdbasource.com> wrote in message news:<y4CPc.2809$wL3.687@newssvr24.news.prodigy.co m>...[color=blue]
> Don Seckler wrote:[color=green]
> > 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!!!![/color]
>
> 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.[/color]
Don Seckler
Guest
 
Posts: n/a
#4: Jul 17 '05

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


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");
?>


djseckler@hotmail.com (Don Seckler) wrote in message news:<fe6bb0b0.0408030511.1236ab50@posting.google. com>...[color=blue]
> 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 <maustin@firstdbasource.com> wrote in message news:<y4CPc.2809$wL3.687@newssvr24.news.prodigy.co m>...[color=green]
> > Don Seckler wrote:[color=darkred]
> > > 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!!!![/color]
> >
> > 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.[/color][/color]
Geoff Berrow
Guest
 
Posts: n/a
#5: Jul 17 '05

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


I noticed that Message-ID:
<fe6bb0b0.0408031453.d76284f@posting.google.com> from Don Seckler
contained the following:
[color=blue]
>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?[/color]

Perhaps it should be $_POST['News_Image_Loc'] ?[color=blue]
>
>2)My Header statement isn't redirecting the browser page. I don't
>know why.[/color]

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/
Don Seckler
Guest
 
Posts: n/a
#6: Jul 17 '05

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


> >1)Everything from the data entry form is going into the db (Thanks to[color=blue][color=green]
> >Michael), except for the data from the News_Image form field into the
> >ImageLoc db field. I can't figure out why?[/color]
>
> Perhaps it should be $_POST['News_Image_Loc'] ?[/color]

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...
[color=blue][color=green]
> >
> >2)My Header statement isn't redirecting the browser page. I don't
> >know why.[/color]
>
> Try a lower case 'h'[/color]

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

But thanks for the suggestions.
Geoff Berrow
Guest
 
Posts: n/a
#7: Jul 17 '05

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


I noticed that Message-ID:
<fe6bb0b0.0408040538.5c0ecca2@posting.google.com > from Don Seckler
contained the following:
[color=blue][color=green]
>> Perhaps it should be $_POST['News_Image_Loc'] ?[/color]
>
>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...[/color]

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?[color=blue]
>[color=green][color=darkred]
>> >
>> >2)My Header statement isn't redirecting the browser page. I don't
>> >know why.[/color]
>>
>> Try a lower case 'h'[/color]
>
>I had a lower case "H" previuosly, and taht wasn't working so I tried
>upper.[/color]

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.[color=blue]
>
>But thanks for the suggestions.[/color]

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/
Don Seckler
Guest
 
Posts: n/a
#8: Jul 17 '05

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


> >I had used News_Image_Loc before and that wasn't working, so I changed[color=blue][color=green]
> >the name of the data entry form text field to News_Image in hope that
> >maybe that would work...[/color]
>
> 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?[/color]

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.

[color=blue][color=green]
> >[color=darkred]
> >> >
> >> >2)My Header statement isn't redirecting the browser page. I don't
> >> >know why.
> >>
> >> Try a lower case 'h'[/color]
> >
> >I had a lower case "H" previuosly, and taht wasn't working so I tried
> >upper.[/color]
>
> Is there anything after it? Try putting exit; after the header
> function.[/color]


I'll have to check.

[color=blue]
> Are you getting an error message? Try removing any white space, like
> between the php tags.[color=green]
> >[/color][/color]

No error, just sticking on the processing page.
Geoff Berrow
Guest
 
Posts: n/a
#9: Jul 17 '05

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


I noticed that Message-ID:
<fe6bb0b0.0408041010.1d758ee5@posting.google.com > from Don Seckler
contained the following:
[color=blue][color=green]
>> right? You're not using an image field and browsing for a picture or
>> anything daft like that?[/color]
>
>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.[/color]

No that's fine.[color=blue]
>
>[/color]
[color=blue][color=green]
>> Are you getting an error message? Try removing any white space, like
>> between the php tags.[color=darkred]
>> >[/color][/color]
>
>No error, just sticking on the processing page.[/color]

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/
Don Seckler
Guest
 
Posts: n/a
#10: Jul 17 '05

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


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 <blthecat@ckdog.co.uk> wrote in message news:<6ka2h0deev327ri9j5ip6sdg18dc2ohi1l@4ax.com>. ..[color=blue]
> I noticed that Message-ID:
> <fe6bb0b0.0408041010.1d758ee5@posting.google.com > from Don Seckler
> contained the following:
>[color=green][color=darkred]
> >> right? You're not using an image field and browsing for a picture or
> >> anything daft like that?[/color]
> >
> >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.[/color]
>
> No that's fine.[color=green]
> >
> >[/color]
>[color=green][color=darkred]
> >> Are you getting an error message? Try removing any white space, like
> >> between the php tags.
> >> >[/color]
> >
> >No error, just sticking on the processing page.[/color]
>
> I think we'll have to see all the code, from both pages.[/color]
Closed Thread