By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

PHP/MySQL array w/zero results

P: n/a
This sql query is good but I'm having trouble echoing the results with
php (no data echoed). Suggestions?

*************
$open_C = 'select * '
. ' from questions , users '
. ' where users . username = "X" LIMIT 0, 30 ';

// Fetch each row of the results into an array $q_row
while ($q_row = @mysql_fetch_array($open_C))
{
echo "ID:\t{$q_row['question']}\n";

}

*************

Thank you.

May 16 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
At Wed, 16 May 2007 12:37:29 -0700, Akhenaten let his monkeys type:
This sql query is good but I'm having trouble echoing the results with
php (no data echoed). Suggestions?

*************
$open_C = 'select * '
. ' from questions , users '
. ' where users . username = "X" LIMIT 0, 30 ';

// Fetch each row of the results into an array $q_row
while ($q_row = @mysql_fetch_array($open_C))
{
echo "ID:\t{$q_row['question']}\n";

}

*************

Thank you.
You have to open a connection to the db and execute the query first, then
fetch rows on the result resource:

<?PHP
$conn = @mysql_connect($host,$user,$pass)
or die (mysql_error());
@mysql_select($dbname)
or die (mysql_error());
$result = mysql_query($open_C, $conn)
or die (mysql_error());
while ($row = mysql_fetch_assoc($result))
// use mysql_fetch_assoc to get the associative array only.
{
echo "ID:\t{$q_row['question']}\n";
}
?>

HTH
Sh.
May 16 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.