[PHP-DB] Re: php/mysql weblog - addnews function problems

2004-02-18 Thread Slippyaah
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/aBR;


   /* 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'TRTD class='BlogTitlebar'Make a new
entry: /TD/TR/TABLE;

   echo TABLE border='0' width='485' class='commentBG';
   echo TRTDTitle: /TD/TRBR;
   echo TRTDinput type='text'  . width='30'
name='title'/TD/TRBR;
   echo TRTDNews: /TD/TRBR;
   echo TRTDTEXTAREA cols='40' rows='5'  .
name='newstext'/TEXTAREA/TD/TRBRBR;
   echo TRTDinput 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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] 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?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: php/mysql weblog - addnews function problems

2004-02-18 Thread Slippyaah
I've tried playing around with it a bit but I'm getting quite confused now.
It still doesn't like my declaration of variables and I'm not sure how to
declare 'id' either as it isn't used in the form as a field of entry - just
an index in the database.

Any help would greatly be appreciated cause I'm using this as an inclusion
in a piece of coursework I'm doing and the deadline is looming! :/

thanks

slippy


Doug Thompson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Wed, 18 Feb 2004 09:35:22 -, Slippyaah wrote:

 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']}');

 I haven't been following this thread, but you need to do your part to help
the parser.

 $query = INSERT INTO news ;
 $query .= VALUES('',$id,'.$_POST['postdate'].',;
 $query .= '.$_POST['title'].',;
 $query .= '.$_POST['newstext'].');

 You should also add some db error checking and reporting, then you
wouldn't get the erroneous success message.

 hth,
 Doug

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] php/mysql weblog - addnews function problems

2004-02-17 Thread Slippyaah
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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php