Jump to content

Archived

This topic is now archived and is closed to further replies.

kusal

session

Recommended Posts

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

Share this post


Link to post
Share on other sites
What exactly is this supposed to do. Can you explain what you are wanting to accomplish.

Share this post


Link to post
Share on other sites
print attribute names one by one

Share this post


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

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.