[PHP] This is weird..whts the prob???

2004-11-05 Thread Aalee
Hi guys,
Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31.
MySQL ver 4.0.20a on winXP pro SP1. This script does not seems to work with
the method of POST. When I change it to GET method the data is entered into
the database, but with POST it does not. I have another script with the POST
method, but that script works with POST. What is wrong with this script.
Here goes the script. What am I doing wrong.

?php
if (isset($_GET['addjoke'])){
?

form name=form1 method=post action=?php $_SERVER['PHP_SELF']; ?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
/form


?php
 }
else { // start main else statement
if(isset ($_POST['insert'])) {
 $db = mysql_connect(localhost,homesite,ju4754) ;
 mysql_select_db(jokes,$db);
 $query = mysql_query(INSERT INTO jokes SET
 JokeText = '.$_POST['jokeText'].' ,
 JokeDate = CURDATE() );
 echo $query;
 echo  Joke inserted, Thank you BRBR;
 echo mysql_error();
}
$color1 = #66CCFF;
$color2 = #66CC99;
$row_count = 1;

// -- Following lines list the jokes in the
database 
echo bH3 These are the jokes we have got so far/H3/B;
$db = mysql_connect(localhost,homesite,ju4754)  or die(mysql_error());
mysql_select_db(jokes,$db);
$sql = SELECT id, JokeText, JokeDate from jokes;
$query = mysql_query($sql);
echo table border=1
   tr
tdbIDb/td
  tdbJoke Textb/td
  tdbJoke Dateb/td/tr;
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echotr bgcolor = $row_color.
  td. $myrow[id]./td.
  td. $myrow[JokeText]. /td.
  td. $myrow[JokeDate]./td/tr;
  $row_count++;
 }
echo /table;

$current_url = $_SERVER['PHP_SELF'];
echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P);


} // end main else statement
?

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



Re: [PHP] This is weird..whts the prob???

2004-11-05 Thread Brent Baisley
The code looks fine to me. You may want to look at the Apache access 
logs to see what is getting submitted to the server when you submit the 
form. Or you can use a network monitoring tool to see what the client 
is submitting.

But, if you can't figure out what is causing the problem, just use 
$_REQUEST instead of $_POST or $_GET. $_REQUEST doesn't care if the 
form was submitted via post or get, it holds the values of either type 
of submission.

Personally, I always like to fix the cause rather than treat the 
symptom. But there isn't always time in the short term.

On Nov 5, 2004, at 7:25 AM, Aalee wrote:
Hi guys,
Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 
1.3.31.
MySQL ver 4.0.20a on winXP pro SP1. This script does not seems to work 
with
the method of POST. When I change it to GET method the data is entered 
into
the database, but with POST it does not. I have another script with 
the POST
method, but that script works with POST. What is wrong with this 
script.
Here goes the script. What am I doing wrong.

?php
if (isset($_GET['addjoke'])){
?
form name=form1 method=post action=?php $_SERVER['PHP_SELF']; 
?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
/form

?php
 }
else { // start main else statement
if(isset ($_POST['insert'])) {
 $db = mysql_connect(localhost,homesite,ju4754) ;
 mysql_select_db(jokes,$db);
 $query = mysql_query(INSERT INTO jokes SET
 JokeText = '.$_POST['jokeText'].' ,
 JokeDate = CURDATE() );
 echo $query;
 echo  Joke inserted, Thank you BRBR;
 echo mysql_error();
}
$color1 = #66CCFF;
$color2 = #66CC99;
$row_count = 1;
// -- Following lines list the jokes in the
database 
echo bH3 These are the jokes we have got so far/H3/B;
$db = mysql_connect(localhost,homesite,ju4754)  or 
die(mysql_error());
mysql_select_db(jokes,$db);
$sql = SELECT id, JokeText, JokeDate from jokes;
$query = mysql_query($sql);
echo table border=1
   tr
tdbIDb/td
  tdbJoke Textb/td
  tdbJoke Dateb/td/tr;
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echotr bgcolor = $row_color.
  td. $myrow[id]./td.
  td. $myrow[JokeText]. /td.
  td. $myrow[JokeDate]./td/tr;
  $row_count++;
 }
echo /table;

$current_url = $_SERVER['PHP_SELF'];
echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P);
} // end main else statement
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] This is weird..whts the prob???

2004-11-05 Thread - Edwin -
Hi,

On Fri, 5 Nov 2004 22:55:20 +1030
Aalee [EMAIL PROTECTED] wrote:

 Hi guys,
 Working on PHP ver 4.3.8 with register_globals turned OFF
 and Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. This
 script does not seems to work with the method of POST. When
 I change it to GET method the data is entered into the
 database, but with POST it does not. I have another script
 with the POST method, but that script works with POST. What
 is wrong with this script. Here goes the script. What am I
 doing wrong.
 
 ?php
 if (isset($_GET['addjoke'])){
 ?
[...]

Try changing that $_GET to $_POST ...

-- 
- E - copperwalls was here ;)

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



Re: [PHP] This is weird..whts the prob???

2004-11-05 Thread dgobrien
Add a 
phpinfo(); 
to the script and see what is getting passed to the page. That has worked wonders for 
me.
-Dave


 
 From: Aalee [EMAIL PROTECTED]
 Date: 2004/11/05 Fri AM 07:25:20 EST
 To: [EMAIL PROTECTED]
 Subject: [PHP] This is weird..whts the prob???
 
 Hi guys,
 Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31.
 MySQL ver 4.0.20a on winXP pro SP1. This script does not seems to work with
 the method of POST. When I change it to GET method the data is entered into
 the database, but with POST it does not. I have another script with the POST
 method, but that script works with POST. What is wrong with this script.
 Here goes the script. What am I doing wrong.
 
 ?php
 if (isset($_GET['addjoke'])){
 ?
 
 form name=form1 method=post action=?php $_SERVER['PHP_SELF']; ?
   Type your joke :br
   textarea name=jokeText id=jokeText/textarea
br
   input name=insert type=submit id=submit value=Insert Joke
 /form
 
 
 ?php
  }
 else { // start main else statement
 if(isset ($_POST['insert'])) {
  $db = mysql_connect(localhost,homesite,ju4754) ;
  mysql_select_db(jokes,$db);
  $query = mysql_query(INSERT INTO jokes SET
  JokeText = '.$_POST['jokeText'].' ,
  JokeDate = CURDATE() );
  echo $query;
  echo  Joke inserted, Thank you BRBR;
  echo mysql_error();
 }
 $color1 = #66CCFF;
 $color2 = #66CC99;
 $row_count = 1;
 
 // -- Following lines list the jokes in the
 database 
 echo bH3 These are the jokes we have got so far/H3/B;
 $db = mysql_connect(localhost,homesite,ju4754)  or die(mysql_error());
 mysql_select_db(jokes,$db);
 $sql = SELECT id, JokeText, JokeDate from jokes;
 $query = mysql_query($sql);
 echo table border=1
tr
 tdbIDb/td
   tdbJoke Textb/td
   tdbJoke Dateb/td/tr;
 while ($myrow = mysql_fetch_array($query))
  {
  $row_color = ($row_count % 2) ? $color1 : $color2;
   echotr bgcolor = $row_color.
   td. $myrow[id]./td.
   td. $myrow[JokeText]. /td.
   td. $myrow[JokeDate]./td/tr;
   $row_count++;
  }
 echo /table;
 
 $current_url = $_SERVER['PHP_SELF'];
 echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P);
 
 
 } // end main else statement
 ?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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