Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.