[thelist] PHP/MySQL odd problem
Mr. Tenuta
dtportnoy at videotron.ca
Fri Jul 9 16:06:58 CDT 2004
>If you already have the query result in a variable, why do you need to
execute the >query again a second time on the same page? Can't you just
reuse the variable you >already have?
Yes I could re-use the same query twice, but there are differences between
the two in the WHERE clause. One i mention freeroll_main and the other
freeroll_list. Whether those categories exist or not there shouldn't be an
error. Let me give you an example of what happening here with the full loop.
// QUERY AND OUTPUT1
// Get query
$res = mysql_query("SELECT * FROM freeroll_menu WHERE category =
'freeroll_main'", $link) or die("Select Failed: " . mysql_error());
// Iteration loop, for each row in rowset
while($row = mysql_fetch_assoc($res))
{
// Assigning variables from cell values to later output
$category = $row["category"];
$link = $row["link"];
$link_name = $row["link_name"];
$order_num = $row["order_num"];
// Output the info
echo "<br>Category: $category<br>Link Name: $link_name<br>Link URL:
$link<br>Order: $order_num<br><br>";
}// end while
... here's the second
// QUERY AND OUTPUT2
// Get query
$res = mysql_query("SELECT * FROM freeroll_menu WHERE category =
'freeroll_list'", $link) or die("Select Failed: " . mysql_error());
// Iteration loop, for each row in rowset
while($row = mysql_fetch_assoc($res))
{
// Assigning variables from cell values to later output
$category = $row["category"];
$link = $row["link"];
$link_name = $row["link_name"];
$order_num = $row["order_num"];
// Output the info
echo "<br>Category: $category<br>Link Name: $link_name<br>Link URL:
$link<br>Order: $order_num<br><br>";
}// end while
... QUERY 1 works while QUERY 2 dies with no error.
If I put QUERY 2 first it works fine, but then QUERY1 won't execute.
It could be a server issue...
Thanks
More information about the thelist
mailing list