Page 1 of 1

concatenating varibles within select function

Posted: Thu Feb 21, 2008 4:05 pm
by billabon0202
I am having trouble writing a select function that uses a predefined variable within call.

***** PLEASE USE THE CODE TAG WHEN POSTING *****

Code: Select all

<?php
$day= date("l"); //gets current name of the day ex. Monday
$cat=strip_tags($_GET['cat']);
$type=strip_tags($_GET['type']);
 
$qry= "SELECT restaurants.rest_id, restaurants.name as name, [color=#FF0000]CONCAT("hours.", $day, "_open")as open, CONCAT("hours.", $day, "_close") [/color]FROM restaurants
INNER JOIN hours
ON restaurants.rest_id = hours.rest_id
INNER JOIN restaurant_info
ON restaurants.rest_id = restaurant_info.rest_id
WHERE restaurants.$cat='yes' AND restaurant_info.food_type=$type";
 
$result= mysql_query($qry);
 
 
Also, does this part look right?
 
if (!$result) {die(mysql_error());
}else{
   while ($row=mysql_fetch_array($result)) {
   $id=$row['restaurant.rest_id'];
   echo '<p>' . $row['name'] . '</p>';
   echo '<p>' . $id . '</p>';
   }
}
?>

Re: concatenating varibles within select function

Posted: Thu Feb 21, 2008 10:28 pm
by califdon
What kind of a problem? Are you getting an error? What error?

Re: concatenating varibles within select function

Posted: Fri Feb 22, 2008 8:55 am
by billabon0202
bParse error: syntax error, unexpected T_STRING in /home/content/b/i/l/billabong0202/html/search.php on line 62

Re: concatenating varibles within select function

Posted: Fri Feb 22, 2008 12:57 pm
by califdon
If we are to help you, you will have to show us the line that is causing the error.