Samuel Vogel wrote:
> Explanation of your code:
>
> $CONTENT = get_content(12, 104, 'merchant');
> echo $CONTENT;
>
> This does not work, because you don't use a "return" in your function.
> This means that the function does not return a value. Now in the
> function you assign a value to $CONTENT. That works, as you pointed out
> with the second example.
> But after that the line above sets $CONTENT to the empty return value of
> the function. And therefore it is empty!
>
> so long,
> Samy
>
Sorry for confusing with 2nd function. Let's take it out, forget about it.
function get_content($client_id, $form_id, $index1)
{
$query = mysql_query("
SELECT content
FROM infos
WHERE client_id=".$client_id."
AND form_id=".$form_id."
AND index1='".$index1."'");
if (mysql_num_rows($query) > 0)
{
$result = mysql_fetch_assoc($query);
return $result['content'];
}
else
{
get_content(0, 0, $index1); // get default value
}
}
$CONTENT = get_content(12, 104, 'merchant');
echo $CONTENT; // empty, nothing
There is "return", right after $result = mysql_fetch_assoc($query);
Some additional info (hopefully will not confuse again :)) I'm pulling
content from table infos for specific client, form and index1. If there
is no record I'm using recursive part (inside "else") to get the default
value (client_id=0, form_id=0).
When echo the content right before "return" I can see it. But can't see
it in echo after calling the function?!?!
thanks
-afan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php