Jump to content

Session not activated


franknu

Recommended Posts

Ok, I have page that carries a session to the next page the problem is that i dont see why this is not carries the the session the next page.

 

here codr for page1

 

<?php
session_start();
$_SESSION['BusinessName'];
?>


<body bgcolor="#E5E5E5" topmargin="0">
<?php

$host = "l";
$username = "";
$password = "";
$database = "";


$db = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

if(isset($_GET['BusinessName'])){


$query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' ";
$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_assoc($result);

$BusinessName= ($row['BusinessName']);
$Keyword =($row['Keyword']);
$Picture1 =  ($row['Picture1']);
$Headline = ($row['Headline']);
$Slogan2 = ($row['Slogan2']);
$Description1 =($row['Description1']);
$Description2 = ($row['Description2']);
$Description3= ($row['Description3']);
$Contact2 =  ($row['Contact2']);
$Picture2 = ($row['Picture2']);
$Picture3 = ($row['Picture3']);
$Business_Address=($row['Business_Address']);
$make=($row['make']);
$type=($row['type']);
$Tel=($row['Tel']);
$Website=($row['Website']);
}
?>
<center>
<table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top">
<?php include("includefiles/banner.php"); ?>
<table width="778" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="778" valign="top">
	<table width="778" border="0" cellpadding="0" cellspacing="0">
          <?php
session_start();
$_SESSION['BusinessName'];
?>
          <tr>
            <td valign="top" bgcolor="#f90102">   <?php
				  echo "<h1><font color='ffffff'><marquee>$BusinessName </marquee></font></h1>"; ?>
</td>

 

here is code for page2

 

<?php
session_start();
$_SESSION['BusinessName'];
?>
<html>
<head>
<title>Untitled Document</title>

</head>

<body bgcolor="#E5E5E5" topmargin="0">
<?php

$host = "localhost";
$username = "";
$password = "";
$database = "";


$db = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

if(isset($_SESSION['$BusinessName'])){
$query = "SELECT * FROM business_info WHERE `BusinessName`='".$_SESSION['$BusinessName']."'";
$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_assoc($result);

$BusinessName= ($row['BusinessName']);
$Keyword =($row['Keyword']);
$Picture1 =  ($row['Picture1']);
$Headline = ($row['Headline']);
$Slogan2 = ($row['Slogan2']);
$Description1 =($row['Description1']);
$Description2 = ($row['Description2']);
$Description3= ($row['Description3']);
$Contact2 =  ($row['Contact2']);
$Picture2 = ($row['Picture2']);
$Picture3 = ($row['Picture3']);
$Business_Address=($row['Business_Address']);
$make=($row['make']);
$type=($row['type']);
$Tel=($row['Tel']);
$Website=($row['Website']);
}
?>
<center>

<?
$_SESSION['BusinessName'];
?>

<pre>_SESSION:<?php print_r($_SESSION); ?></pre>



<table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top">
<?php include("includefiles/banner.php"); ?>
<table width="778" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="778" valign="top">
	<table width="778" border="0" cellpadding="0" cellspacing="0">
          
          <tr>
            <td valign="top" bgcolor="#f90102">   <?php
				  echo "<h1><font color='ffffff'><marquee>$BusinessName </marquee></font></h1>"; ?>
</td>

]

 

 

Link to comment
https://forums.phpfreaks.com/topic/53753-session-not-activated/
Share on other sites

You are not using the session variables correctly, for example in your code above I notice you do this:

<?php
session_start();
$_SESSION['BusinessName'];
?>

All the code does is start the session, you only need to use session_start(); once when you want to use sessions. In your code you use it more than once. But having $_SESSION['BusinessName']; on its own directly after session_start(); does nothing.

 

When you want to use the 'BuisnessName' session variable you use $_SESSION['BusinessName'] variable, not $BusinessName or $_SESSION['$BusinessName'] variables as I have seen you use a few times in your code.

 

So if you make a few corrections here an there you code should work how you want it.

Link to comment
https://forums.phpfreaks.com/topic/53753-session-not-activated/#findComment-265735
Share on other sites

ok I screw up something here now it is not even selecting from my database

 

this are the new changes i made

 

page1

 


<?php
session_start();
$_SESSION['BusinessName'] ='$BusinessName';
$_SESSION['BusinessName'];

?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#E5E5E5" topmargin="0">
<?php

$host = "";
$username = "";
$password = "";
$database = "";


$db = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());


if(isset($_SESSION['$BusinessName'])){
$query = "SELECT * FROM business_info WHERE `BusinessName`='".$_SESSION['$BusinessName']."'";

$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_assoc($result);

$BusinessName= ($row['BusinessName']);
$Keyword =($row['Keyword']);
$Picture1 =  ($row['Picture1']);
$Headline = ($row['Headline']);
$Slogan2 = ($row['Slogan2']);
$Description1 =($row['Description1']);
$Description2 = ($row['Description2']);
$Description3= ($row['Description3']);
$Contact2 =  ($row['Contact2']);
$Picture2 = ($row['Picture2']);
$Picture3 = ($row['Picture3']);
$Business_Address=($row['Business_Address']);
$make=($row['make']);
$type=($row['type']);
$Tel=($row['Tel']);
$Website=($row['Website']);
}
?>
<center>
<table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top">
<?php include("includefiles/banner.php"); ?>
<table width="778" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="778" valign="top">
	<table width="778" border="0" cellpadding="0" cellspacing="0">
          <?php
$_SESSION['BusinessName'];
?>
          <tr>
            <td valign="top" bgcolor="#f90102">   <?php
				  echo "<h1><font color='ffffff'><marquee>$BusinessName </marquee></font></h1>"; ?>
</td>
          </tr>

Link to comment
https://forums.phpfreaks.com/topic/53753-session-not-activated/#findComment-265747
Share on other sites

You are getting there but you are still not accessing your variables correctly. For example these lines:

session_start();
$_SESSION['BusinessName'] ='$BusinessName';
$_SESSION['BusinessName'];

 

Should be just lthis:

session_start();

You don't need to initialize your variable yet. You do that later on in your code. Which will be this section:

if(isset($_SESSION['$BusinessName'])){
$query = "SELECT * FROM business_info WHERE `BusinessName`='".$_SESSION['$BusinessName']."'";

 

BUt here you are using the wrong of sort of syntax for using your session variable. You should use $_SESSION['BusinessName'] not $_SESSION['$BusinessName']

 

And then further on down this:

<?php
$_SESSION['BusinessName'];
?>
          <tr>
            <td valign="top" bgcolor="#f90102">   <?php
				  echo "<h1><font color='ffffff'><marquee>$BusinessName </marquee></font></h1>"; ?>
</td>
          </tr>

Can be just this:

<tr>
            <td valign="top" bgcolor="#f90102">   <?php
				  echo "<h1><font color='ffffff'><marquee>{$_SESSION['BusinessName']}</marquee></font></h1>"; ?>
</td>
          </tr>

Link to comment
https://forums.phpfreaks.com/topic/53753-session-not-activated/#findComment-265777
Share on other sites

Ok this line:

 

 

 

is stoping the database from displaying any data

<?php

session_start();

$_SESSION['BusinessName'] ='$BusinessName';

$_SESSION['BusinessName'];

 

?>

 

and here is the raw code so maybe i can get a better idea on this.

 

this code actually display nicely just the way it is, i just want to create the BusinessName Session

which has turn into a headache

 

 


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#E5E5E5" topmargin="0">
<?php

$host = "localhost";
$username = "townsfin_localho";
$password = "abc123";
$database = "townsfin_contacts";

$db = mysql_connect($host, $username, $password) or die(mysql_error()); 
mysql_select_db($database) or die(mysql_error()); 

if(isset($_GET['BusinessName'])){ 


$query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' "; 
$result = mysql_query($query) or die (mysql_error()); 
$row = mysql_fetch_assoc($result); 

$BusinessName= ($row['BusinessName']); 
$Keyword =($row['Keyword']); 
$Picture1 =  ($row['Picture1']); 
$Headline = ($row['Headline']); 
$Slogan2 = ($row['Slogan2']); 
$Description1 =($row['Description1']); 
$Description2 = ($row['Description2']); 
$Description3= ($row['Description3']); 
$Contact2 =  ($row['Contact2']); 
$Picture2 = ($row['Picture2']); 
$Picture3 = ($row['Picture3']); 
$Business_Address=($row['Business_Address']); 
$make=($row['make']); 
$type=($row['type']); 
$Tel=($row['Tel']); 
$Website=($row['Website']); 
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/53753-session-not-activated/#findComment-265802
Share on other sites

ok, i think, that i am getting punish here, but those are my new changes

 

maybe it make more sense to you guys, now.

 

<?php

$db = mysql_connect($host, $username, $password) or die(mysql_error()); 
mysql_select_db($database) or die(mysql_error()); 


$BusinessName = (isset($_GET['BusinessName']) ? $_GET['BusinessName'] : '');
$Slogan = (isset($_GET['Slogan']) ? $_GET['Slogan']:'');
$Business_Address = (isset($_GET['Business_Address']) ? $_GET['Business_Address']:'');
$Tel = (isset($_GET['Tel']) ? $_GET['Tel']:'');
$Website = (isset($_GET['Website']) ? $_GET['Website']:'');
$Email = (isset($_GET['Email']) ? $_GET['Email']:'');
$Member_Status = (isset($_GET['Member_Status']) ? $_GET['Member_Status']:'');
$Fax =(isset($_GET['Fax']) ? $_GET['Fax']:'');
$type = (isset($_GET['type']) ? $_GET['type']:'');
$make = (isset($_GET['make']) ? $_GET['make']:'');
$Categories = (isset($_GET['Categories']) ? $_GET['Categories']:'');
$Keyword = (isset($_GET['Keyword']) ? $_GET['Keyword']:'');
$Picture1 =  (isset($_GET['Picture1']) ? $_GET['Picture1']:'');
$Headline =  (isset($_GET['Headline']) ? $_GET['Headline']:'');
$Slogan2 = (isset($_GET['Slogan2']) ? $_GET['Slogan2']:'');
$Description1 = (isset($_GET['Description1']) ? $_GET['Description1']:'');
$Description2 = (isset($_GET['Description2']) ? $_GET['Description2']:'');
$Description3= (isset($_GET['Description3']) ? $_GET['Description3']:'');
$Contact2 = (isset($_GET['Contact2']) ? $_GET['Contact2']:'');
$Picture2 =  (isset($_GET['Picture2']) ? $_GET['Picture2']:'');
$Picture3 = (isset($_GET['Picture3']) ? $_GET['Picture3']:'');
$Picture4 =  (isset($_GET['Picture4']) ? $_GET['Picture4']:'');
$User_Name = (isset($_GET['User_Name']) ? $_GET['User_Name']:'');
$Password = (isset($_GET['Password']) ? $_GET['Password']: '');
$User_Name=strtolower($_GET['User_Name']);
$Password=strtolower($_GET['Password']);

if(isset($_GET['BusinessName'])){ 


$query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' "; 
$result = mysql_query($query) or die (mysql_error()); 
$row = mysql_fetch_assoc($result); 

$BusinessName= ($row['BusinessName']); 
$Keyword =($row['Keyword']); 
$Picture1 =  ($row['Picture1']); 
$Headline = ($row['Headline']); 
$Slogan2 = ($row['Slogan2']); 
$Description1 =($row['Description1']); 
$Description2 = ($row['Description2']); 
$Description3= ($row['Description3']); 
$Contact2 =  ($row['Contact2']); 
$Picture2 = ($row['Picture2']); 
$Picture3 = ($row['Picture3']); 
$Business_Address=($row['Business_Address']); 
$make=($row['make']); 
$type=($row['type']); 
$Tel=($row['Tel']); 
$Website=($row['Website']); 
} 
?> 


<center>
<table width="200" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td valign="top">
<?php include("includefiles/banner.php"); ?>
<table width="778" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="778" valign="top">
	<table width="778" border="0" cellpadding="0" cellspacing="0">
      <tr>
            <td valign="top" bgcolor="#f90102">   <?php
				  echo "<h1><font color='ffffff'><marquee>$BusinessName </marquee></font></h1>"; ?>
</td>

Link to comment
https://forums.phpfreaks.com/topic/53753-session-not-activated/#findComment-265868
Share on other sites

Archived

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

×
×
  • Create New...

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.