Please help me.

I got this error while uploading in Server. I developed this code in windows based. But the deployed server is Linux Server. In windows server i didn't get this session error.

Here is my code:

<?php session_start();
require_once('l2t_connect.php');
if($_GET['action'] == "send")
{
	if(isset($_REQUEST['btnSend']))
	 {
		$key=substr($_SESSION['key'],0,5);
      		$number = $_REQUEST['number'];
		if($number!=$key)
	  	{
         	 	$message = "Please enter the correct Code!";
	    	}
     }
}
<?php } ?>

Thank you in advance!!!!!!

That last line would have been a real bug. Try the following:

<?php session_start();
require_once('l2t_connect.php');
if($_GET['action'] == "send")
{
if(isset($_REQUEST['btnSend']))
    {
    $key=substr($_SESSION['key'],0,5);
    $number = $_REQUEST['number'];
    if($number!=$key)
        {
        $message = "Please enter the correct Code!";
        }
    }
}

Also make sure l2t_connect.php does not contain session_start(). Good luck.

Thank you for your reply.
But the Same error comes again. This is my Actual coding.

<?php session_start();
require_once('l2t_connect.php');
if($_GET['action'] == "send")
{
 if(isset($_REQUEST['btnSend']))
 {
  $key=substr($_SESSION['key'],0,5);
  $number = $_REQUEST['number'];
  if($number!=$key)
  {
    $message = "Please enter the correct Code!";
  }
  else
  {
      $sqlAdd="INSERT INTO l2t_enquiry (name, email, conno, comment, is_answered, is_deleted)
      VALUES
      (  '".$_POST['enq_name']."', 
         '".$_POST['emailid']."',
         '".$_POST['conno']."',
         '".$_POST['comments']."',
         'true',
         'true')";
      $resultAdd = mysql_query($sqlAdd);
  }
 }
}
?>

Perhaps php short tags might make a difference. Below is an example and I fixed a mysql bug at the same time.

<? session_start();
require_once('l2t_connect.php');
if($_GET['action'] == "send")
{
if(isset($_REQUEST['btnSend']))
{
$key=substr($_SESSION['key'],0,5);
$number = $_REQUEST['number'];
if($number!=$key)
{
$message = "Please enter the correct Code!";
}
else
{
$sqlAdd="INSERT INTO l2t_enquiry (name, email, conno, comment, is_answered, is_deleted) VALUES ( '".
mysql_real_escape_string($_POST['enq_name'])."', '".mysql_real_escape_string($_POST['emailid']).
"', '".mysql_real_escape_string($_POST['conno'])."', '".mysql_real_escape_string($_POST['comments']).
"', 'true', 'true')";
$resultAdd = mysql_query($sqlAdd);
}
}
}
?>

If that doesn't work then make sure there are no spaces/tabs before the <? as that will also cause an error. Also please use code tags like I have above as it make the code so much more readable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.