mikesta707 Posted January 30, 2009 Share Posted January 30, 2009 Hey, I can't figure out what is wrong with my code. I have tried a bunch of ways to make the code work, but it doesn't. here is the code: Code: <? $sql = mysql_query("SELECT fid FROM facebook WHERE uid='$user_id'"); if (!$sql) {//test if SQL was valid echo "There was an error"; print mysql_error(); exit(); } $array = mysql_fetch_array($sql, MYSQL_ASSOC);//mysql_assoc because the array doesn't function properly without it $i = 1;// array entry number echo "<h2><fb:name uid='$user_id' possessive='true' useyou='false' /> Stoner Friends</h2><br>";//output. you can ignore this echo sizeof($array) . "<br>";//just to test how big the array is is. foreach ($array as $fid) {//my array loop echo "$i: <fb:name uid='$fid' /><br>"; $i++;//update entry number } ?> by the way the stuff that looks like <fb:xxxx /> is FBML, the markup language used for facebook apps $user_id is set in my config file, and I have even tried making it global. the variable works in every other page i've used it for. I have tried an @ infront of mysql_fetch_array. What should output is: 1. friend 1 2. friend 2 3. friend 3 What it is outputting is: 1. friend 1 It gets the right info for the first entry, but doesn't output the rest of the information on my table. I have no clue why. I have tried different types of loops, different variable combination's, and all sorts of stuff. the SQL validity check runs true, so I don't think the SQL is wrong, plus it returns the first row correctly. I really have no clue why this doesn't work at all. Can anyone else make any sense of my problem? Thanks a lot in advance if anyone can help me or lead me in the right direction. Link to comment https://forums.phpfreaks.com/topic/143089-solved-code-that-should-work-but-doesnt/ Share on other sites More sharing options...
mikesta707 Posted January 30, 2009 Author Share Posted January 30, 2009 nevermind i fixed it Link to comment https://forums.phpfreaks.com/topic/143089-solved-code-that-should-work-but-doesnt/#findComment-750432 Share on other sites More sharing options...
fenway Posted February 2, 2009 Share Posted February 2, 2009 nevermind i fixed it Please share the details of your solution before marking it "solved". Link to comment https://forums.phpfreaks.com/topic/143089-solved-code-that-should-work-but-doesnt/#findComment-752434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.