[PHP] Cannot retrive the data ???

2004-11-01 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Hi there,
Look at the following code please. I have  a mysql db setup and apache 
running. I have the register_globals=OFF on the php.ini file. The code is
suppose to show all the jokes in the databse and give user to enter jokes.
The code works fine when when the register_globals=ON in the php.ini file.
But for some reason it does not work when it is OFF. Infact when it is OFF
it give a blank page with no data retrieved from the databse and gives no
errors. Please help me.Code is below...

?php
if (isset($_GET[addjoke])){
?
form name=form1 method=post action=?php echo ($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 {
 //'.$_POST['jokeText'].'
if($insert){
$db = mysql_connect(localhost,homesite,951753)  or
die(mysql_error()) ;
if (!$db){
echo  Cannot connect to MySQL server. Please check the server connection;
}
mysql_select_db(jokes,$db);
$query = mysql_query(INSERT INTO jokes SET
JokeText = '.$_POST['jokeText'].' ,
JokeDate = CURDATE() );
if(mysql_affected_rows($query) != 0){   
echo  Joke inserted, Thank you BRBR;
} 
else { echo Joke NOT entered. An error occured while entering; }

$color1 = #CCFFCC; 
$color2 = #BFD8BC; 
$row_count = 0;

// -- Following lines list the jokes 
echo b These are the jokes we have got so far/BBR;
$db = mysql_connect(localhost,homesite,951753)  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.
 td bgcolor=$row_color. $myrow[id]./td.
 td bgcolor=$row_color. $myrow[JokeText]. /td.
 td bgcolor=$row_color. $myrow[JokeDate]./td/tr;
// echo .$myrow[id].-- . $myrow[JokeText].   . $myrow[Name].
 .$myrow[Email]. BRBR;
 $row_count++; 
}
echo(PA HREF='$PHP_SELF?addjoke=1' .Add a Joke!/A/P);

}
?

Cheers Mike

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



[PHP] Cannot retrive the data ???

2004-11-01 Thread PHPDiscuss - PHP Newsgroups and mailing lists
Hi there,
Look at the following code please. I have  a mysql db setup and apache 
running. I have the register_globals=OFF on the php.ini file. The code is
suppose to show all the jokes in the databse and give user to enter jokes.
The code works fine when when the register_globals=ON in the php.ini file.
But for some reason it does not work when it is OFF. Infact when it is OFF
it give a blank page with no data retrieved from the databse and gives no
errors. Please help me.Code is below...

?php
if (isset($_GET[addjoke])){
?
form name=form1 method=post action=?php echo ($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 {
 //'.$_POST['jokeText'].'
if($insert){
$db = mysql_connect(localhost,homesite,951753)  or
die(mysql_error()) ;
if (!$db){
echo  Cannot connect to MySQL server. Please check the server connection;
}
mysql_select_db(jokes,$db);
$query = mysql_query(INSERT INTO jokes SET
JokeText = '.$_POST['jokeText'].' ,
JokeDate = CURDATE() );
if(mysql_affected_rows($query) != 0){   
echo  Joke inserted, Thank you BRBR;
} 
else { echo Joke NOT entered. An error occured while entering; }

$color1 = #CCFFCC; 
$color2 = #BFD8BC; 
$row_count = 0;

// -- Following lines list the jokes 
echo b These are the jokes we have got so far/BBR;
$db = mysql_connect(localhost,homesite,951753)  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.
 td bgcolor=$row_color. $myrow[id]./td.
 td bgcolor=$row_color. $myrow[JokeText]. /td.
 td bgcolor=$row_color. $myrow[JokeDate]./td/tr;
// echo .$myrow[id].-- . $myrow[JokeText].   . $myrow[Name].
 .$myrow[Email]. BRBR;
 $row_count++; 
}
echo(PA HREF='$PHP_SELF?addjoke=1' .Add a Joke!/A/P);

}
?

Cheers Mike

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



Re: [PHP] Cannot retrive the data ???

2004-11-01 Thread Janet Valade
PHPDiscuss - PHP Newsgroups and mailing lists wrote:
Hi there,
Look at the following code please. I have  a mysql db setup and apache 
running. I have the register_globals=OFF on the php.ini file. The code is
suppose to show all the jokes in the databse and give user to enter jokes.
The code works fine when when the register_globals=ON in the php.ini file.
But for some reason it does not work when it is OFF. Infact when it is OFF
it give a blank page with no data retrieved from the databse and gives no
errors. Please help me.Code is below...

?php
if (isset($_GET[addjoke])){
?
form name=form1 method=post action=?php echo ($PHP_SELF); ?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
/form
With register_globals off, you need to use $_SERVER['PHP_SELF']. You 
possibly have your errors turned off in php.ini. Check that 
error_reporting is E_ALL and display_errors is on.

Janet
--
Janet Valade -- janet.valade.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Cannot retrive the data ???

2004-11-01 Thread Jack . van . Zanen
Try

if($_POST[insert])

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 01, 2004 5:08 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Cannot retrive the data ???


Hi there,
Look at the following code please. I have  a mysql db setup and apache 
running. I have the register_globals=OFF on the php.ini file. The code is
suppose to show all the jokes in the databse and give user to enter jokes.
The code works fine when when the register_globals=ON in the php.ini file.
But for some reason it does not work when it is OFF. Infact when it is OFF
it give a blank page with no data retrieved from the databse and gives no
errors. Please help me.Code is below...

?php
if (isset($_GET[addjoke])){
?
form name=form1 method=post action=?php echo ($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 {
 //'.$_POST['jokeText'].'
if($insert){
$db = mysql_connect(localhost,homesite,951753)  or
die(mysql_error()) ;
if (!$db){
echo  Cannot connect to MySQL server. Please check the server connection;
} mysql_select_db(jokes,$db); $query = mysql_query(INSERT INTO jokes SET
JokeText = '.$_POST['jokeText'].' ,
JokeDate = CURDATE() );
if(mysql_affected_rows($query) != 0){   
echo  Joke inserted, Thank you BRBR;
} 
else { echo Joke NOT entered. An error occured while entering; }

$color1 = #CCFFCC; 
$color2 = #BFD8BC; 
$row_count = 0;

// -- Following lines list the jokes  echo b
These are the jokes we have got so far/BBR; $db =
mysql_connect(localhost,homesite,951753)  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.
 td bgcolor=$row_color. $myrow[id]./td.
 td bgcolor=$row_color. $myrow[JokeText]. /td.
 td bgcolor=$row_color. $myrow[JokeDate]./td/tr;
// echo .$myrow[id].-- . $myrow[JokeText].   .
$myrow[Name].  .$myrow[Email]. BRBR;
 $row_count++; 
}
echo(PA HREF='$PHP_SELF?addjoke=1' .Add a Joke!/A/P);

}
?

Cheers Mike

-- 
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