I'm having trouble with an SQL query. I need the the query to query multipule times but it also needs to have a different value each time for this variable $shop_db[$i]['shop_owner'] but as you can see from the error it doesn't seem to pick up the value of the variable.
This is the error message.
SQL Error : 1064 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 3
SELECT username FROM phpbb_users WHERE user_id =
Line : 172
And this is the code.
$a = 0;
while ( $row = $db->sql_fetchrow($result) )
{
$shop_db[$a] = $row;
$a++;
}
for ( $i = 0; $i < $s; $i++ )
{
//
// BEGIN GET OWNER NAME
//
$user_id[$i] = $shop_db[$i]['shop_owner'];
$sql = "SELECT username
FROM ".USERS_TABLE."
WHERE user_id = ".$shop_db[$i]['shop_owner']; // this is where the error is.
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query shops', '', __LINE__, __FILE__, $sql); // this is line 172.
}
$row = $db->sql_fetchrow($result);
$s_owner[$i] = $row['username'];
//
// END GET OWNER NAME
//
$template->assign_block_vars('shop_loop',array( 'SHOP' => $shop_db[$i]['shop_name'],
'S_DESC' => $shop_db[$i]['shop_desc'],
'S_OWNER' => $s_owner[$i],
'U_SHOP' => "?page=3&shop_id=".$shop_db[$i]['shop_id'] ) );
}
any help is greatly appreciated.