concatenating varibles within select function

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
billabon0202
Forum Newbie
Posts: 8
Joined: Wed Feb 20, 2008 11:31 am

concatenating varibles within select function

Post 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>';
   }
}
?>
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: concatenating varibles within select function

Post by califdon »

What kind of a problem? Are you getting an error? What error?
billabon0202
Forum Newbie
Posts: 8
Joined: Wed Feb 20, 2008 11:31 am

Re: concatenating varibles within select function

Post by billabon0202 »

bParse error: syntax error, unexpected T_STRING in /home/content/b/i/l/billabong0202/html/search.php on line 62
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: concatenating varibles within select function

Post by califdon »

If we are to help you, you will have to show us the line that is causing the error.
Post Reply