"annabelle.imray" <[EMAIL PROTECTED]> wrote in message
9ehff1$jda$[EMAIL PROTECTED]">news:9ehff1$jda$[EMAIL PROTECTED]...
> I have been given an example of how to use php & mysql from a hosting
> company. They have the following function:
>
> #====
> function ExecuteQuery ($linkdb, &$queryresult, $querytext) {
>
> $queryresult = mysql_query($querytext, $linkdb);
>
> if (($queryresult != false) and (mysql_errno() == 0)) {
> return true;
> } else {
> return false;
> }
> }
> #====
>
> And an example of it's usage:
>
>
> $query = "SELECT * FROM test";
>
> if ($mysql_result = mysql_query($query, $linkdb)) {
> if (ExecuteQuery($linkdb, $result, $query)) {
> while ($row = NextRow($result)) {
> print('"'.$row[1].'" : "'.$row[2].'"<br>');
> }
> }
> }
>
> Can anyone tell me why the first "if" exists in their usage example, e.g.
if
> ($mysql_result = mysql_query($query, $linkdb)) {
>
> As the $mysql_result variable is not used after this statement and the
query
> is performed again in the ExecuteQuery() function;
>
> As I have said, am I missing something important here?
>
> Thanks
What wasteful code. It seems to execute the same query twice
It would be more practical to return the result of the query in the function
then you can remove the first 'if' then
good luck
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]