dog199200 Guest | API Error (11th Feb 11 at 11:19am UTC) | | Forum URL: http://www.shiningashes.vforums.us Site URL: http://www.shiningashes.net/
Problem:
 Code: - Warning: Invalid argument supplied for foreach() in /home/REMOVED/public_html/index.php on line 71
Ross,
For some reason since the migration to the new server i've been getting this error because of the API system. I can no longer login via my website, or anything else. I had changed nothing within my programming. Here is the codes i've been using incase its a problem resulting in something being changed within the API:
Code Giving The Error:
 Code: - <?php
- $news_articles = $vforums_api -> get_recent(Array(
- "board" => "publicupdates",
- "mode" => "topics",
- "show_locked" => "1",
- "allow_all" => "1",
- "max" => "1"
- ));
- foreach($news_articles as $post) {
- ?>
-
- <div class="content">
- <h2>News</h2>
- <div class="text">
- <div class="right"><?=date('l dS \of F Y', $post['timestamp']);?></div>
- <h4 class="subject"><u><?=$post['subject'];?></u></h4>
- <blockquote><?=$post['message'];?></blockquote>
- <div style="text-align : right;">~ <b><?=$post['display_name'];?></b></div>
- </div>
- </div>
-
- <?php
- }
- ?>
API Include Statement:
 Code: - <?php
- include_once('/home/REMOVED/public_html/includes/vforums_api.php');
- $vforums_api = new vforums_api('shiningashes.vforums.us', 'REMOVED');
-
- $user_info = $vforums_api -> login_user("user", "pass");
- $logged_in = $user_info? true : false;
- ?>
Then i'm calling it into every page using:
 Code: - include("/home/REMOVED/public_html/includes/forumdata.php");
| |
|
Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: API Error (11th Feb 11 at 11:32am UTC) | | Should be good now.
BTW, do not post your API key anywhere that anyone can see it. It effectively gives someone access to all areas of your forum. I would recommend you change it ASAP. | |
|
|
dog199200 Guest | Re: API Error (11th Feb 11 at 11:34am UTC) | | Ah yeah, forgot to remove it, sorry i'm tired. And thanks for fixing it. What was wrong if you don't mind me asking | |
|
Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: API Error (11th Feb 11 at 1:28pm UTC) | | Ah yeah, forgot to remove it, sorry i'm tired. And thanks for fixing it. What was wrong if you don't mind me asking
Lets just say there was nothing wrong on your side | |
|
|
dog199200 Guest | Re: API Error (12th Feb 11 at 12:35am UTC) | | I kind of figured that considering nothing got changed and it got fixed | |
|
dog199200 Guest | Re: API Error (13th Feb 11 at 2:53am UTC) | | Gah, Ross same error as above, same site:
"Invalid argument supplied for foreach() in /home/REMOVED/public_html/spanel/staffm.php on line 44"
The members list function isn't working | |
|
Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: API Error (13th Feb 11 at 1:20pm UTC) | | Can you provide me with an example of a page this is happening on or the code you are using to call the API. There is nothing in the error log this time. | |
|
|
dog199200 Guest | Re: API Error (14th Feb 11 at 1:24pm UTC) | | Ok here is the code. I cant give you a link to the page since the page is private. I just know I had it working before the server move and after it stopped working.
 Code: - <?php
- $member_list = $vforums_api -> get_members($max = "100");
-
- echo "<table cellpadding=\"5\" cellspacing=\"1\" border=\"1\" width=\"100%\">
-
- <tr>
- <td width=\"30%\">
- <h4>NAME</h4>
- </td>
- <td width=\"30%\">
- <h4>RANK</h4>
- </td>
- <td width=\"30%\">
- <h4>Modifications</h4>
- </td>
- </tr>
-
- ";
-
- foreach($member_list as $member) {
- ?>
-
- <tr>
- <td width=\"30%\">
- <a href="http://www.shiningashes.vforums.us/profile/<?=$member['user_name'];?>"><?=$member['display_name'];?></a>
- </td>
- <td width=\"30%\">
- <?=$member[rank][1][name];?>
- </td>
- <td width=\"30%\">
- Edit - <a href="mailto:<?=$member['e-mail'];?>">Email</a>
- </td>
- </tr>
-
- <?php
- }
- echo "</table>";
- ?>
| |
|
Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: API Error (14th Feb 11 at 1:50pm UTC) | | A couple of bits to change:
$member_list = $vf -> get_members($max = "100");
to
$member_list = $vf -> get_members(Array("max" => "100"));
<?=$member['e-mail'];?>
to
<?=$member['email'];?>
and
<?=$member[rank][1][name];?>
to
<?=$member['rank'][1]['name'];?>
Other than that, should now be working. | |
|
|
dog199200 Guest | Re: API Error (14th Feb 11 at 10:15pm UTC) | | Ah ok, thats weird because it was working just fine in the past and I didn't change anything. Oh well thanks Ross, it works now. | |
|