Cannot retrive the data ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <BR><BR>";
} 
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</B><BR>";
$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>
	  	<td><b>ID<b></td>
		<td><b>Joke Text<b></td>
		<td><b>Joke Date<b></td></tr>";
while ($myrow = mysql_fetch_array($query))
	{
	$row_color = ($row_count % 2) ? $color1 : $color2;
	 echo"<tr>".
	 "<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"]. "<BR><BR>";
	 $row_count++; 
	}
echo("<P><A 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux