hi i have a problem please help me
for($i=0;$i!=mysql_num_rows($result);$i++)
{
$play=mysql_result($result,$i);
session_start();
$_SESSION['$movie'] = $play;
?>
<a class="play" href="player.php"><?php print ($play).'</br></br>';}?></a>
where is my code is wrong ?
move session_start()
before your for-cycle
session_start();
for($i=0;$i!=mysql_num_rows($result);$i++)
{
$play=mysql_result($result,$i);
$_SESSION['$movie'] = $play;
?>
<a class="play" href="player.php"><?php print ($play).'</br></br>';}?></a>
session_start();
for($i=0;$i!=mysql_num_rows($result);$i++){
$play=mysql_result($result,$i);
$_SESSION['$movie'] = $play;
print( '<a class="play" href="player.php">' . $play . '</br></br></a>');
}
?>
You have an additional error where your open a tag is repeated, but your closing a tag is outside the for loop. Your $_SESSION['$movie'] variable is only going to have the final value of $play in it, too - meaning that it's pretty much a waste of processor time to set it over and over and over again.
pay attention to this : if your file Unicode is : UTF-8 or something like this , you'll see this error by PHP Set your Unicode to UTF-8 without BOM if you're going to write in other languages
<?php
session_start();
...
?>
Note the <?php
instead of <?
- this did the trick for me, when session_start()
wasn't working.
Also, you wanna make sure your code is placed on top of the php document.
session_start must be mention on the top of your script and there should not put/write any code before it. like:
<?php
session_start();
?>
// other stuff or page start here
----OR ----
You may check your page, in which you have already started session.