0

Originally I was trying to solve this issue:

403 Error Persists After Changing File Permissions & Editing Htaccess File

Before I make too many changes to my code I would like to understand the problem.

After the suggestion of @misorude I checked the PHP error logs for the directory that the code causing the error existed in. I found the following error.

[12-Jan-2019 15:23:49 America/Chicago] PHP Warning: Invalid argument supplied for foreach() in /home/bullbusterweb/public_html/community/profile.php on line 898

I have tried the following to understand this issue.

1) I googled what invalid argument supplied for foreach() could mean and found the following result.

Invalid argument supplied for foreach()

2) Then I looked at my code to see what could be causing this.

The foreach in question was here:

'''php
 foreach($Articles as $Article){
'''

The first place 'Articles is defined is

$Articles = $Ambassador->getArticles();

A few lines above the foreach() I found the following code related to the articles variable.

    // var_dump($Articles);
if(isset($Articles)){

According to the php manual:

var_dump :  "Dumps information about a variable" .  
isset:  " Determines if a variable is set and is not NULL"

I tried uncommenting the var_dump but found that it messed up the formatting of the page. So now I know why it is commented out.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
  • This doesn't look to have anything to do with Javascript. Please tag your questions appropriately – CertainPerformance Jan 12 '19 at 22:22
  • `var_dump` is commented out so it won't execute. `isset()` only determines if the variable has a value other than null. There's not enough info to determine what's going on in your code, but the invalid argument for foreach is caused by `$Articles` not being [`iterable`](https://secure.php.net/manual/en/language.types.iterable.php). Please show the code where `$Articles` is being declared. ie `$Articles = ....` – Will B. Jan 12 '19 at 22:32
  • Regarding the var_dump and isset() in the first sentence, that is already covered in the question. $Articles = is also in the question but I can put it here as well: $Articles = $Ambassador->getArticles(); – Stochastic Holdings Jan 12 '19 at 22:38
  • Can you post an example of your .htaccess – Jonny Jan 12 '19 at 23:17
  • I retract my previous comments. This appears to be an extension of your other question. Short answer is typically no, you would receive a 500 error page from Apache. Long answer is it depends on what is occurring in your app, an error handler could be redirecting to a page that does not permitted or sending a `header('status: 403')`. response. – Will B. Jan 12 '19 at 23:50

0 Answers0