Obsession Posted May 20, 2009 Share Posted May 20, 2009 I get "Resource ID #3" for the result of a query, which has me completely baffled. Any ideas? The code that generates this answer- <?php $con=mysql_connect('localhost','root',''); mysql_select_db('LolStrat',$con); $Champion=$_GET['Champion']; echo $Champion; $Tag=mysql_query("SELECT Tag FROM champions WHERE Name='$Champion'"); echo "<br>"; echo $Tag; ?> The first part works, it fetches the champion name from the URL and prints that. Then I want the query to find the tag of that champion, easily enough explained by the query. I thought $Tag would therefore be "The ChronoKeeper", which is what the database has for that record, only it prints "Resource id #3" in those exact words... Ideas? Thanks. Edit- After a bit more googling, I got some examples and tried those, to no success. <?php $con=mysql_connect('localhost','root',''); mysql_select_db('LolStrat',$con); $Champion=$_GET['Champion']; echo $Champion; $queryone=mysql_query("SELECT Tag FROM champions WHERE Name='$Champion'"); $Tag=mysql_fetch_row($queryone); echo "<br>"; echo $Tag; ?> This generates the word "Array" for $Tag, when it should be "The ChronoKeeper". I also tried Mysql_fetch_object and got a fatal error, could not convert to string. Really confused... 2nd Edit- <?php $con=mysql_connect('localhost','root',''); mysql_select_db('LolStrat',$con); $Champion=$_GET['Champion']; echo $Champion; $queryone=mysql_query("SELECT Tag FROM champions WHERE Name='$Champion'"); $query_row=mysql_fetch_array($queryone); echo($query_row[Tag]); ?> This code generates Zilean Notice: Use of undefined constant Tag - assumed 'Tag' in C:\wamp\www\LolStrategy\ViewChampion.php on line 30 The ChronoKeeper Now If i could just get rid of that notice, i'm done! Any ideas at all? Link to comment https://forums.phpfreaks.com/topic/158998-solved-resource-id-3/ Share on other sites More sharing options...
Obsession Posted May 20, 2009 Author Share Posted May 20, 2009 Sorry all, problem solved, after ALOT of searching. Used this- while ($row = mysql_fetch_assoc($queryone)) { echo $row['Tag']; } Didnt even think a while loop would help. Link to comment https://forums.phpfreaks.com/topic/158998-solved-resource-id-3/#findComment-838532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.