Saturday, 24 August 2013

Script works with PHP 5.4.16, but not PHP 5.3.3... where is the faulty code?

Script works with PHP 5.4.16, but not PHP 5.3.3... where is the faulty code?

I'm a beginner in php, and... I was just trying to create this... dynamic
indexing/document_display script using php... What I was trying to do
isn't really important to the question, however. The thing is... my script
does exactly what I want it to do, when hosted on a WAMP server with php
5.4.16... but when uploaded to a LAMP server with php 5.3.3, I get the
error
Fatal error: Can't use function return value in write context in
/users/clentz/testphpindex.php on line 34
I need it to work on this lamp server.
Can anyone tell me what about the following code is causing errors with
the php 5.3.3 interpreter?
<?php
$courses_directory = "./Courses";
$courses_array = scandir($courses_directory);
if (empty($_SERVER['QUERY_STRING']))
{
include 'Misc/common_components/headers/index_header.html';
echo "\r\n\t<h1>Enrolled Courses</h1>";
for ($uwmi_loop_var = 2; isset($courses_array[$uwmi_loop_var]);
$uwmi_loop_var++)
{
if ($uwmi_loop_var == 2)
{
echo "\r\n\t<ul>";
}
if (isset($courses_array[$uwmi_loop_var]))
{
echo "\r\n\t\t<li>" . '<a href="?' .
$courses_array[$uwmi_loop_var] . '">' .
$courses_array[$uwmi_loop_var] . '</a></li>';
}
if (!isset($courses_array[($uwmi_loop_var + 1)]))
{
echo "\r\n\t</ul>\r\n";
}
}
include 'Misc/common_components/footer.html';
}
else if (!empty($_SERVER['QUERY_STRING']))
{
for ($uwmi_loop_var = 2; isset($courses_array[$uwmi_loop_var]);
$uwmi_loop_var++)
{
if (explode("&",$_SERVER['QUERY_STRING'])[0] ==
rawurlencode($courses_array[$uwmi_loop_var]))
{
include "./Courses/" . $courses_array[$uwmi_loop_var] .
"/index.php";
}
}
}
?>
If it helps, you can see the code in a little more visually appealing
format at: pic of the code in a visually appealing format

No comments:

Post a Comment