Jump to content

Printing variable within variable


Jacko623

Recommended Posts

Hi,

 

This should be a fairly simple error, but I cannot figure it out.

 

Depending on the day, I am pulling two sets of information from a specific database. If one is null, the other should be printed. Simple enough. But i'm receiving the following error:

 

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/J/m/i/Jmisarti/html/test/happyhour.php on line 42

 

Line 42 is bolded below:

 

<?php

//Connect
$ConDB=mysql_connect($hostname,$username,$password);
$DB=mysql_select_db($dbname,$ConDB);

//Day Variables
$today = getdate();
$d = "$today[wday]";
if ($d == 0) { $dday = ('Sun'); }
if ($d == 1) { $dday = ('Mon'); }
if ($d == 2) { $dday = ('Tues');}
if ($d == 3) { $dday = ('Wed'); }
if ($d == 4) { $dday = ('Thur');}
if ($d == 5) { $dday = ('Fri'); }
if ($d == 6) { $dday = ('Sat'); }

echo ("Today is $dday");
echo ("day <br><br>");

$hh = "hh$dday";
$ns = "ns$dday";

echo ("hh$dday");
echo ("<br> $hh");

//Query Happy Hour
$queryD = "SELECT bar_user_id,$hh,$ns FROM partynj_bar_calendar WHERE $hh OR $hh <> NULL Order by Rand() limit 0,1";
$resultD = mysql_query($queryD) or die("Problem with the query <pre>$queryD</pre><br>" . mysql_error());

if (mysql_num_rows($resultD) == 1) 
{
	$rwD = mysql_fetch_assoc($resultD);
	if (($rwD["$hh"]) == NULL)
	{
	echo ("<br> Tonight's specials are : ")
	[b]print_r ($rwD["$ns"]);[/b]
	} 
	echo ("<br> Tonight's happy hour special is : ");
	print_r ($rwD["$hh"]);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/39082-printing-variable-within-variable/
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.