Jump to content


Photo

session


  • Please log in to reply
3 replies to this topic

#1 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 13 July 2006 - 06:30 AM

<?php
session_start();
ob_start(); //Turn on output buffering
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root123"; // Mysql password
$db_name="test"; // Database name

$tbl=$_POST['rating'];

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="describe $tbl";
$result=mysql_query($sql);

$count=mysql_num_rows($result);


global $x;

for($x=0; $x<$count; $x++){         
$newArray = mysql_fetch_array($result);
$aa=$newArray['Field'];

$_SESSION[$x]=$aa;
}



?>
<a href="dynamic2.php">dynamic2</a>



//dynamic2.php

<?php

session_start();
$one=$_SESSION['0'];

echo "$one";

?>


Notice: Undefined offset: 0 in c:\Inetpub\wwwroot\test\dynamic2.php on line 4



what is the problem here?
www.kuppiya.com

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 13 July 2006 - 07:06 AM

What exactly is this supposed to do. Can you explain what you are wanting to accomplish.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 13 July 2006 - 07:09 AM

print attribute names one by one
www.kuppiya.com

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 13 July 2006 - 12:09 PM

The array index '0' is different from the array index 0. Remove the single quotes from the line
<?php $one=$_SESSION['0']; ?>
.  Also, why are you buffering your output when you're not doing any output?

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users