Skoff
Новичок
Не получается составить функцию!
Всем привет, вот написанная функция:
function construction()
{
global $db_id;
$query = "select * from buildings where type = (select b1 from links where id=".$town[0].")";
$res = mysql_query($query) or die(mysql_error());
$number = mysql_num_rows($res);
if ($number == 0) {
return "";
} else {
$constr_str = "";
while ($row=mysql_fetch_array($res)) {
$constr_str .= $row['construction'];
}
}
return $constr_str;
}
Выводит такую лабуду: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1"
если меняю переменную $town[0] на значение, то все идет гладко, в чем проблема? помогите пожалуйста!
Всем привет, вот написанная функция:
function construction()
{
global $db_id;
$query = "select * from buildings where type = (select b1 from links where id=".$town[0].")";
$res = mysql_query($query) or die(mysql_error());
$number = mysql_num_rows($res);
if ($number == 0) {
return "";
} else {
$constr_str = "";
while ($row=mysql_fetch_array($res)) {
$constr_str .= $row['construction'];
}
}
return $constr_str;
}
Выводит такую лабуду: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1"
если меняю переменную $town[0] на значение, то все идет гладко, в чем проблема? помогите пожалуйста!