rackemup420
rackemup420

Reputation: 1567

MySQL Query Isnt Returning A Result

i got a fairly simple layout going and for the life of me i cant figure out why this returns nothing:

<?php
// Gets A List Of Comic Arcs
$result = mysql_query("SELECT * FROM ".$db_tbl_comics." GROUP BY ".$db_fld_comics_arc." ORDER BY ".$db_fld_comics_date." DESC LIMIT 20");
while ($comic = mysql_fetch_array($result)) {

// Now Go Back And Count Issues For Each Comic Arc Above
$result22 = mysql_query("SELECT * FROM ".$db_tbl_comics." WHERE ".$db_fld_comics_arc."=".$comic[$db_fld_comics_arc]);
$total_issues = mysql_num_rows($result22);
echo $total_issues; 
}
?>

No other query is refered to as $result22.

$comic[] has already been defined in the previous query.

echo mysql_error($result22); returns no errors.

Let me know if you need any other info.

Upvotes: 0

Views: 69

Answers (2)

Nonym
Nonym

Reputation: 6299

I am assuming that the column $db_fld_comics_arc is a string.

Change:

$result22 = mysql_query("SELECT * FROM ".$db_tbl_comics." WHERE ".$db_fld_comics_arc."=".$comic[$db_fld_comics_arc]);

To:

$result22 = mysql_query("SELECT * FROM ".$db_tbl_comics." WHERE ".$db_fld_comics_arc."='".$comic[$db_fld_comics_arc]."'");

Am I wrong? If so, let me know the table structure, and what your error reporting is set to.

Also, could you let us know the purpose of your SQL? It may also be possible to put the data together in one query, instead of looping sql queries through, and using data from a first query.

Upvotes: 1

AlphaPhantom
AlphaPhantom

Reputation: 13

Maybe it is because $db_fld_comics_arc is in $comic[$db_fld_comics_arc]

if both are the same then you should try replacing $db_fld_camics_arc with $comic[$db_fld_comics_arc].

Upvotes: 0

Related Questions