Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You obviously have the numbers coming out that you're expecting to see (1-6), because you are printing them to the screen. You've tried a suggestion of using <code>trim</code> which didn't get you any further.</p> <p>My presumption is that your <code>echo</code> used for debugging is places outside your <code>if</code> statement, and that your <code>if</code> statement isn't running every time you expect it to. Firstly, try putting your <code>echo</code> inside the <code>if</code> statement to make sure that your output is the same, then put <code>var_dump($pagePath);</code> into it as well to ensure that your variable is what you're expecting.</p> <p>Another thing you could try, you could make sure the file exists:</p> <pre><code>echo (file_exists($pagePath)) ? 'Exists' : 'Does not exist...'; </code></pre> <p>You could post us the code in your included files to check that you aren't overwriting variables like <code>$x</code> or <code>$pageNum</code> etc from your includes - variables are global between includes and will overwrite eachother.</p> <p>Finally, I know you'll have a good explanation for this, but this looks pretty longwinded to me, in <strong>this particular</strong> application, you could just do this:</p> <p>for($i = 1; $i &lt;= 6; $i++) { include 'page' . $i . '.php'; }</p> <blockquote> <p>SIDE NOTES:</p> </blockquote> <p><strong>mysql_*</strong> functions are deprecated and you should be using either PDO or <code>mysqli</code>. Resources: - <a href="http://php.net/manual/en/book.pdo.php" rel="nofollow">http://php.net/manual/en/book.pdo.php</a> - <a href="http://php.net/manual/en/book.mysqli.php" rel="nofollow">http://php.net/manual/en/book.mysqli.php</a></p> <p>PHP's <a href="http://php.net/manual/en/function.include.php" rel="nofollow">include function</a> is a language control structure, not a function, so shouldn't be used with brackets: (for you downvoters, I'm <strong>not saying it can't</strong>, I'm saying it shouldn't)</p> <pre><code>// good: include 'filename.php'; // bad: include('filename.php'); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload