Jump to content


Photo

i'm confused variables not taking the value


  • Please log in to reply
4 replies to this topic

#1 ankycooper

ankycooper
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 23 August 2006 - 11:24 AM

i have a code as follows
<?php
session_start();
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true || 

!isset($_SESSION['info']) || $_SESSION['info'] !== true) {
	// not logged in, move to login page
	header('Location: index.php');
	exit;
}


include 'dbinfo.inc.php';
@mysql_connect($host,$user_name,$pass_word)or die( "Unable to Connect to database");
@mysql_select_db($database) or die( "Unable to select database");
$username=$_SESSION['username'];

$sql = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error()); 
list($id, $usnme, $specialty, $p, $name, $bdname, $tlname, $mgrname, $myno, $bdno,  $tlno, 

$mgrno, $mymail, $bdmail, $tlmail, $mgrmail, $myt, $bdt, $tlt, $mgrt) = 

mysql_fetch_array($result, MYSQL_NUM);

$sqlsugg = "SELECT * FROM mf where mfname='openingmail'";
$resultsugg = mysql_query($sqlsugg) or die('Query failed. ' . mysql_error());  
list($mfid, $mfname, $mfcon) = mysql_fetch_array($resultsugg, MYSQL_NUM) or die('Query 

failed. ' . mysql_error());  

$srx="333";
$cname="1111";
$issue="3333";
$cmail="3333";

$mfcone=$mfcon;
echo $mfcone;

	?>

it echo's  value of $mfcone as

Hello $cname, Thank you for contacting Support. I am the Support Professional who will work with you on the case '$srx'. You can reach me using the contact information mentioned below. Please be sure to include your case number. As discussed, the issue we are trying to resolve is '$issue' We would consider this incident completed and closed only when the issue is resolved. Hope we are on the same page with the understanding of the issue. Thank you for calling


and does not include the value of the variables


$srx="333";
$cname="1111";
$issue="3333";

Please Help

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 23 August 2006 - 11:29 AM

I see $mfcon is coming from a your mf table in the database. What does $mfcon hold?

#3 ankycooper

ankycooper
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 23 August 2006 - 11:33 AM

The $mfcon has

Hello $cname, Thank you for contacting Support. I am the Support Professional who will work with you on the case '$srx'. You can reach me using the contact information mentioned below. Please be sure to include your case number. As discussed, the issue we are trying to resolve is '$issue' We would consider this incident completed and closed only when the issue is resolved. Hope we are on the same page with the understanding of the issue. Thank you for calling

but it is  not taking up the values of the variables
$srx="333";
$cname="1111";
$issue="3333";

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 August 2006 - 11:38 AM

When you retreive $mfcon from the database, it's just a string. PHP doesn't look at it to make any variable substitutions. You either need to pass it through the eval() function or use the str_replace() function to get the variable names replaced with their values.

Ken

#5 ankycooper

ankycooper
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 23 August 2006 - 11:48 AM

Thanks Man eval("\$mfcon = \"$mfcon\";");
worked for me




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users