I think I have a scoping misunderstanding. Probably from my previous C coding adventures.
In brief I have:
index.php: shown below
main.php: as you guessed, is the "main program" with several "program wide" variables such as $CrwdMvImg1. Also has "require" statements for five other php files reflecting various functional groupings (file handling, data handling, etc)
I tried to create a new php file just with the imagepng calls but cannot get it to work because of various program wide variables such as $CrwdMvImg1.
But in testing I found that if I DO NOT HAVE LINE 9 in index.php, "require MM_Main.php", I DO NOT get the Notice: Undefined index: image_id in C:\AppServ\www\MM_Main.php on line 94 messages. And my images appear fine. BUT if I then also try to output text, no text appears and the images become empty boxes.
If I DO HAVE LINE 9 in index.php, "require MM_Main.php", I DO get the Notice: Undefined index: image_id in C:\AppServ\www\MM_Main.php on line 94 messages, as before. But I can output data. (Besides the call to show_calcs(), I also have print statements throughout my code for testing purposes.) The images appear fine.
I am at a loss. Other than functions calls for my MM_Main.php "program wide" variables to yet another new php file, or user defined global variables (which I view as a dangerous coding practice) I am not sure how to proceed. Is there some way I can test the $_GET variables? It appears they are empty when I include line 9 in index.php. No idea why that would happen.
Hope that is all clear! One thing certainly is clear, your patience and generosity in guiding me through this issue is exemplary! You raise the bar for all of us.
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My PHP Catastrophe</title>
</head>
<body>
<?php
require("MM_Main.php"); //The line that solves or causes problems, why does this break $_GET for image_id?
show_calcs($SlowAry,"Slow Array", $Symbol, $SlowMaxBar); //data output func. Other funcs also use print statements
?>
<p>
<img src="MM_Main.php?image_id=1" border="0">
<img src="MM_Main.php?image_id=2" border="0">
<img src="MM_Main.php?image_id=3" border="0">
<img src="MM_Main.php?image_id=4" border="0">
</p>
</body>
</html>