PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
franknu
Forum Contributor
Posts: 146 Joined: Sun May 28, 2006 9:29 am
Post
by franknu » Thu May 31, 2007 11:10 am
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
Code: Select all
<?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
Code: Select all
<?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>
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Thu May 31, 2007 11:27 am
You never give $_SESSION['BusinessName'] a value.
And, so you know, you only run session_start() once, and just typing $_SESSION['BusinessName'] does nothing.
franknu
Forum Contributor
Posts: 146 Joined: Sun May 28, 2006 9:29 am
Post
by franknu » Thu May 31, 2007 12:09 pm
what happend is that BusinessName value com from the database
how should i set it up
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Thu May 31, 2007 12:12 pm
Start with $_SESSION['BusinessName'] = ....
franknu
Forum Contributor
Posts: 146 Joined: Sun May 28, 2006 9:29 am
Post
by franknu » Thu May 31, 2007 12:48 pm
ok I screw up something here now it is not even selecting from my database
this are the new changes i made
page1
Code: Select all
<?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>
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Thu May 31, 2007 12:56 pm
1) Please, get rid of the blank calls to $_SESSION['BusinessName']... They do nothing.
2) Where are you getting $BusinessName from, and why is it in single quotes?
3) Why is there a dollar sign in your array index in your query?
franknu
Forum Contributor
Posts: 146 Joined: Sun May 28, 2006 9:29 am
Post
by franknu » Thu May 31, 2007 1:42 pm
Ok this line:
is stoping the database from displaying any data
Code: Select all
<?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
Code: Select all
<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']);
}
?>
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu May 31, 2007 1:47 pm
take a look at the output of
Code: Select all
<?php
$var = 'xyz';
echo ' $var ';
echo " $var ";
echo $var;
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Thu May 31, 2007 1:48 pm
Code: Select all
<?php
if(isset($_GET['BusinessName'])){
$query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' ";
$result = mysql_query($query) or die (mysql_error());
?>
$BusinessName is not set to anything.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Thu May 31, 2007 1:50 pm
Well, your problem lies in awaiting PHP to somehow translate what you want. It won't.
At any point, do you assign a value to $BusinessName?
franknu
Forum Contributor
Posts: 146 Joined: Sun May 28, 2006 9:29 am
Post
by franknu » Thu May 31, 2007 2:11 pm
well that is saying if BusinessName is true
which it is the problem is not selecting BusinessName
my problem is creating a Session on that page so i can take it to another page.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Thu May 31, 2007 2:24 pm
No, your query says:
Code: Select all
SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName'
Which, since you haven't given a value to $BusinessName, is actually this:
Code: Select all
SELECT * FROM business_info WHERE `BusinessName`= 'NULL'
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Thu May 31, 2007 2:39 pm
Don't forget the undefined variable notice that is thrown with that query as well.
franknu
Forum Contributor
Posts: 146 Joined: Sun May 28, 2006 9:29 am
Post
by franknu » Thu May 31, 2007 3:43 pm
ok, i think, that i am getting punish here, but those are my new changes
maybe it make more sense to you guys, now.
Code: Select all
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>