Re: php/mysql weblog - addnews function problems
| From: | Slippyaah | Date: | Wed, 18 Feb 2004 09:35:22 +0000 |
| Subject: | Re: php/mysql weblog - addnews function problems | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-32996@lists.php.net to get a copy of this message | ||
Hey David,
Well basically I think it's a problem with the declaration of variables
and/or the way they are being processed by the form.
Here is the individual addNews function:
function addNews() {
global $db;
/* declare variables here? */
/* insert the new news entry */
$query = "INSERT INTO news" .
"VALUES('',$id,'{$_POST['postdate']}'," .
"'{$_POST['title']}',".
"'{$_POST['newstext']}')";
/* if statement to process the input? */
mysql_query($query);
echo "New News Entry Added!<BR>\n";
echo "<a href='{$_SERVER['PHP_SELF']}" .
"?action='addNews'>Back to Blog</a><BR>";
/* adds a form where the administrator to add news */
echo "<HR width='400'><BR>";
echo "<FORM
action=".$_SERVER['PHP_SELF']."?action='addNews'
method=POST>";
echo "<TABLE width='485'><TR><TD
class='BlogTitlebar'>Make a new
entry: </TD></TR></TABLE>";
echo "<TABLE border='0' width='485'
class='commentBG'>";
echo "<TR><TD>Title: </TD></TR><BR>";
echo "<TR><TD><input type='text' " .
"width='30'
name='title'></TD></TR><BR>";
echo "<TR><TD>News: </TD></TR><BR>";
echo "<TR><TD><TEXTAREA cols='40' rows='5' " .
"name='newstext'></TEXTAREA></TD></TR><BR><BR>";
echo "<TR><TD><input type='submit' name='submit'
value='submit'";
"<input type='hidden' name='action'
value='addNews'>";
echo "</FORM></TD></TR>";
echo "</TABLE>";
echo "<BR>";
echo "<HR width='400'>";
}
and here is the error it produces so far (obviously I know that as it is it
wont work but my problem is that I don't know exactly what to do to it go
get it to work...:P)
Notice: Undefined variable: id in
c:\inetpub\wwwroot\webdev\phpblog\site\PHPblog.php on line 266
Notice: Undefined index: postdate in
c:\inetpub\wwwroot\webdev\phpblog\site\PHPblog.php on line 266
Notice: Undefined index: title in
c:\inetpub\wwwroot\webdev\phpblog\site\PHPblog.php on line 267
Notice: Undefined index: newstext in
c:\inetpub\wwwroot\webdev\phpblog\site\PHPblog.php on line 268
New News Entry Added!
Back to Blog
Slippy
"David Robley" <robleyd@ozemail.com.au> wrote in message
news:MPG.1a9db3c7931628d8989859@news.php.net...
> In article <20040217222042.48316.qmail@pb1.pair.com>,
> slippyaah@hotmail.com says...
> > hey,
> >
> > I've been working on a PHP/MYSQL weblog and I've got most of it working
> > apart from the adding new news function and a login section. I've set
the
> > form up but it is coming up with a few errors and the actual submitting
of
> > data doesn't work as of yet. The code is too long to include in this
post
> > and its hard to explain exactly where it is going wrong because I'm
fairly
> > new to PHP and MYSQL - this is my first stab at them both.
> >
> > Just wandering if anyone could take a couple of minutes to look at my
php
> > code and tell me what is wrong with it? (it's probably something
blindingly
> > obvious;))
> >
> > thanks very much
> >
> > slippy
> >
>
> Perhaps if you were to post the errors returned and the few lines of code
> leading up to the line where the error occurs...
>
>
> --
> Quod subigo farinam
>
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet?