GD Functions - Creating A "Simple" Image
I want to create a "simple" square image at a variable height & width.. the image would be either transparent or perhaps use a background color.. And contain a "number" positioned in the top left corner maybe like:
-----------------
- 1 -
-----------------
Like I said "simple".. since I've yet to look into this, and I've yet to work with the gd library.. I'm wondering if someone can point me to some "examples".. Or perhaps, you already have a function to do just that..
I'm starting to work on a little calendar function, which I've written already.. I basically want to make it a little "schedular" app.. I want to create the image for an "onclick" event.. which opens a "view" of the selected day(s) event(s)...
The image will give those (who use those "ancient" browsers) something to click on.. since some older browser do not support "onClick" event assigned to a table cell.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Imagejpeg Generating String Not Image Even With Header("Content-type:image/jpeg")
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header doesn't make a difference at all. <?php //random_number.php $img_number = imagecreate(100,50); $white = imagecolorallocate($img_number,255,255,255); $black = imagecolorallocate($img_number,0,0,0); $grey_shade = imagecolorallocate($img_number,204,204,204); imagefill($img_number,0,0,$grey_shade); ImageRectangle($img_number,5,5,94,44,$black); ImageRectangle($img_number,0,0,99,49,$black); header("Content-type:image/jpeg"); imagejpeg($img_number); ?>
How Do I Do Something Like $color = ("red", "yellow", "blue")[$colornum]?
How do I take an index of a literal array, instead of a variable? That is, say I want to get the short name of a month. Can I do something like: $monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$month]; or do I always have to do: $blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthname = $blah[$month]; It seems a shame to have to create a variable specifically for this one-shot purpose.
Create Functions In "main" That Requires Objects
I have a function query(String $query) in my DbConnector-class- goes like this: function query($query) { $mysqlQuery = mysql_query($query, $this->link); if(!$mysqlQuery){ $this->setError("Queryfeil: ".mysql_error()); return false; } return $mysqlQuery; } and the fetchArray($result)-function: function fetchArray($result) { $output = mysql_fetch_array($result); if(!$output){ $this->setError("Feil under henting fra databasen: ".mysql_error()); return false; } return $output; } then I have my "main"-page, where I try to make a function listSections()- like this: function listSections(){ $sections = $connector->query("select * from section");<-- line 27 while($result= $connector->fetchArray($sections)){ print("<option>".$result['name']."</option> "); } }
Creating A Product "activation Key" For Php Scripts?
I'm try to figure out the best way to create a "license key" for php scripts. Basically the key would be unique to the user and if valid would unlock the script. I'm guessing the code that deciphers the key would need to be encoded with ioncube or something similar so that it couldn't be circumvented. Any ideas on how to approach this?
Creating "newspaper Column" Output
Anyone out there have any tricks or scripts to take some text of unknown length and display it in two (or more) columns of equal height? The text may or may not contain "hard-coded" linebreaks or other formatting such as [UL]s. why there's not a columns tag in HTML is mystery: <COLUMNS col=3> wouldn't this be grand </COLUMNS>
Call_user_func() Vs. "variable Functions"
I was looking at the PHP function "call_user_func()" (http://us3.php.net/call_user_func). It appears that this will solve a design problem in the app I'm working on. (I'm writing a class that will allow a PHP programmer to call their own custom functions.) However, in the comments a couple people mention "variable functions". E.g., "You should avoid this function and use variable function calls instead!" What are "variable functions"?
Functions "compiled" Each Time?
I have an index.php file that has a lot of functions that I wrote. Let's say for the sake of argument that there are 1000 functions of 100 lines each. The index.php file is invoked with a "state" a la "index.php?state=L1-2L3C4-47". Different functions are called according to what the state is, and then user actions can cause index.php to be invoked again with a different state. For instance, you can click an "erase this part" button, and the page will display again with that part missing. I don't mind if it takes even a second or two to "compile" (parse? condense?) the functions the first time through, but a change of state should take only 1/10 of a second or less. Apart from the compiling, that goal is achievable, the processing isn't that complicated, but if the php engine starts from scratch each time I pass through the file, I will have a problem. Or maybe, since it is a server-side process, rather than compiling the functions once for each contact with the page, the functions are compiled once when the first person contacts the page. I just have no idea how it works, and I need to know so I can plan my code accordingly.
"Flexible" Functions A Possibility?
Is it at all possible in PHP to have "flexible" functions? For example, there's a function which has 3 parameters, and I only want to utilize 2 - the first one and last one. Instead of typing myFunc('first', false, 'third'); Could I/how would I do this? myFunc('first', $thirdparam = 'third'); (Assuming $thirdparam is the same variable used to declare the third parameter when creating the function.)
Preventing Visitors Ability To "re-visit" A Page Via The "back Button"..
I have a rather complex registration/member sign up form.. which gets a little confused, when a visitor "backs" completely out of the form, then for whatever reason returns to the form. The form contains 'cancel' buttons, which naturally cancel the reg process and redirects them to the document just before they started. JS provides us with the "location.replace()" method, but I can't seem to find a way to coordinate the use of location.replace() with the posting of the form values. In short, I want to "replace" the first step of the form with the "second step". I think what's making this tricky, is that each step of the form are located within the "same" page (register.php). The document works like so: The first step is the "Member Agreement" when they click "agree" (submit) the system creates a new row in the temporary register table of the db. It then issues a registration cookie, which carries the row id, and session value. in addition (for those cookie impared users) we carry the row id and session value in hidden elements. So far, as long as the user continues through the process all is fine, but if they (for whatever reason) back all the way out, and click 'agree' again, the process fails. I guess I have to find a way to force a reload of the 1st step "if they've gone back" OR "replace()" the first step with the second, so as to prevent the user from going "back" to the 1st step of the register page.
Creating "dynamic" Links
I am creating a directory of local business where I live and need some help on the navigation I want to build for the site. How it works: I have 8 categories at the top of the page (Dining, Bars, Entertainment, etc). When a user clicks on say the Dining button, it loads client_list.php and lists all businesses under that category. Then on the left it loads a list of the sub categories (Pizza, Chinese, Fast Food, etc). I have all that working, but what I want to do is when a user clicks on one of those side categories it loads a page called client_filter.php and loads only the businesses under that sub-category (say all the businesses under Pizza). Now I have that link code partially done: client_filter.php/?category=$category_num& but how do I code in the sub_category id number so that is only displays the Pizza places. If any needs to see any of the other code just let me know. Just don't want to show to much for security and such.
Pagnation - Limit Number Of Pages Between "Previous" & "Next" Hyperlinks
Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages? Code:
Losing $_POST Data With Input Type="image"
I am having problems with a php script that I am developing. I have a file called "login.php". It contains an HTML form with a username and password field, and is submitted with an image. Here is a simplified version of my form: <form name="form1" action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <input type="text" size="20" maxlength="50" class="text" name="uname"> <input type="password" size="20" maxlength="12" class="text" name="passwd"> <input type="image" src="images/b-login.jpg" border="0" name="submit"> </form> As you can see, the script calls itself. However, when I try to access $_POST['uname'] and $_POST['password'], they do not exist. If I replace the line <input type="image" src="images/b-login.jpg" border="0" name="submit"> with <input type="submit" name="submit" value="Login"> everything works fine. I need to use this image to submit my form, not the standard "Submit" button. Any ideas on what the problem is?
[regex] Stripping Out "name" And "value" Values Out Of Tags, Aaargh
Searched through the site, but couldn't find the right regex syntax I was looking for. the thing i want is, to extract with preg_match_all the given values in a tag... ex. $str = '<input type="text" name="name" value="value">' $pattern = some magic stuff I need to know preg_match_all($pattern, $str, $result); And in result I want to have the values text, name and value AND it's important that the order doesn't matter so structure of tags can be <input type =name= value=> or <input name= class= value= type=> etc, etc...
'Parse Error' Problem In "isset" And "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "isset", however, testing with "is_null" or "is_int" produces the correct ("success"/"failure") result. Any ideas?
Input Type="image" $_POST Queries
I'm trying to set up a 'control panel' consisting of a table of icons. The early stages: http://www.deepinit.com/controlcentre.php Each of these is set up like: <td> <input type="image" id="addnews" src="/Image/add24.png" name="addnews" value="addnews" width="24" height="24"><br /> <label for="addnews">Add News Item</label><br /> </td> This is all taking place in a html form and I'm using input type="image"... like 'submit' buttons. Is this a 'good' approach? I'm trying to handle the $_POST variable after a user clicks on one of these but there are differences between firefox and ie6. Using: foreach ($_POST as $key=>$val) { echo $key ."|". $val . "<br />"; } ie6 is only listing addnews_x|8 addnews_y|17 Firefox: addnews_x|10 addnews_y|13 addnews|addnews Why am I getting x and y co-ordinates? Why in firefox do I get $val ('addnews|addnews') but not in ie6? What I'm trying to do is redirect to other pages based on $_POST: foreach ($_POST as $key=>$val) { switch (strtolower($key)) { case 'addnews_x': PostHandler('addnews', 'news', '/posteditor.php'); break; case 'editnews_x': PostHandler('editnews', 'news', '/postsearch.php'); break; case 'deletenews_x': PostHandler('deletenews', 'news', '/postsearch.php'); break; ... function PostHandler($command, $post_type, $redir_page) { $_SESSION['ctlcentcmd'] = $command; $_SESSION['posttype'] = $post_type; ob_end_clean(); header('Location: http://' . $_SERVER['HTTP_HOST'] . $redir_page); } This is working but I'm not happy basing this on the x co-ordinate (eg addnews_x). Surely there must be a better way? If you wanted to implement a similar icon based 'Control Centre' what approach would you take? The intent is to have a single page where the site admin can add/edit/delete news, articles, bios, user data, etc
Simple "foreach"
I'm getting into PHP and I have a decent sized MySQL/PHP database system working fine but I'm having problems with the foreach command... When I get the info from a MySQL database I usually use the following command to assign a variable to each value: foreach ($row as $key => $value) {$$key = $value;} This works perfectly but I was wondering is there a way to check something like $datestamp vs $new_datestamp and $timestamp vs $new_timestamp by doing something like this code below? foreach ($row as $key => $value) { $$key = $value; if ($new_$$key==$$key){echo "$new_$$key is same as old $$key, which is $value "; } I know this doesn't work above but I'm presuming it's something to do with my syntax... I've had a look at PHP.net tutorials and done a bit of googling but I'm lost on this simplest of all problems... I could do it the long way with like 20 conditions but I want to get more efficient in my programming.
Saving An Image From A "file" Form?
How do I recieve a picture from a form off a website and save it to a directory? I use the "file" form to allow the user to browse their local drive but how do I get the actual picture so I couild use it later?
Write Text To An "image-page"
If I generate an image, is it possible to write text on the same page then? If it isn't so, there's no special meaning to generate images, who wants to surf on a page that is out of content, right? <? Header("Content-Type: image/gif"); $img = ImageCreate(100, 100); $black = ImageColorAllocate($im, 0, 0, 0); ImageFill($img, 100, 100, $black); ImageGIF($img); ?>
I'm Getting "out Of Memory" Errors When Trying To Resize An Image
I've a jpeg image that is 514k, which doesn't strike me as very large. Yet I'm running out of error when I try to resize it: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 12288 bytes) in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageToSquare.php on line 82 How can I protect against out-of-memory errors?
Echo "<!--#include File="top.html" -->";
I have a search script which returns a page of results, however I'd like the returned page to be in the same format as the rest of my site. To do this I've tried adding the HTML for my site to my PHP page with echo" " commands. This works for the plain HTML, but my regular pages also use SSI to do other stuff (some of them even execute other PHP scripts to generate tables of data etc). I've tried echo "<!--#include file="top.html" -->"; but it doesn't work as I get a parse error. My question is, how do I go about doing this properly? Is this possible at all? And if not have you guys got any suggestions to get around this?
Any File Size Limit In <PARAM Name="***" Value="***"> ?
I embed an applet in my php script which has a parameter providing an input file for the jar. Does this file has size limit? The code is as follows: <APPLET ARCHIVE="myapplet.jar" WIDTH=372 HEIGHT=360 VSPACE=0 HSPACE=0 ALIGN=middle> <?php echo "<PARAM NAME="data" VALUE="myfile.">";?> when "myfile" is beyond 15M, my applet cannot load sucessfully, but while this file is limited like 5M or 7M, it works well. Does anybody know is the reason caused by php script limit, applet mechanism, or by different browser?
How To Do PHP "require()" Or TCL "source" In Bash Script
I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone really know bash script well please help, it's a barrier for me not to be able to get just this one piece working.
Headers For "image Not Found" Image
I'd like to serve an image-not-found image for images... that aren't found.. I'm already using a custom 404 handler page.. but this question could apply to images retrieved from a database or script or whatever... Anyhow, is the 1st method OK, or should #2 be used? ie, does the client/bot or whatever recognize the 404 on method 1? Or, does it think everything is dandy because of the redirect. header('HTTP/1.0 404 Not Found'); header('location: '.$image_url); exit; or header('HTTP/1.0 404 Not Found'); header('Content-Type: image/whatever'); readfile($imagefilepath); exit is one way more better?
"Streaming" Image Files
I would like to stream image files from a directory so that the end user cannot see the actual file path of the image. For instance, I would have an image directory named "bob" and a PHP script/function that sends it to the browser like this: Code: <img src="someFunction.php?img=the_image_name.jpg"> I've seen this done with other languages, but how do you do it in PHP?
File Uploading; "image/jpg"
I've created a file upload for images, and would like to duplicate one for other files that do not include images, with limitations (i.e., I don't want people uploading .exes, .ppts, etc). Is there a list of all of the file types and extensions? Y'know, like "image/jpg", "image/png", etc? The reason I'm asking is because I'm not sure what I should type before "/ext" ("movie/wmv"?), Word document ("word/doc"?), or other files.
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
Image "stitching" With GD - Help
I have (what seems to be) a rather simple problem I'd like to solve using PHP with the GD library installed. I would like to "stitch" multiple images together so that they appear next to each other, but create a new file while doing this. For example, lets say I have 5 images named 1.gif through 5.gif, each containing the digits 1-5 respectively. I would like use GD to place them next to each other in a new image (1 single image), so they read "12345" when displayed in the browser. I do not want to have the 5 images simply displayed next to each other.
Coding "NEXT" And "PREVOIUS" Buttons
Hi I am stuck here. I am doing a form which dispalys details of client companies. My query includes this statement: .... WHERE CompanyName LIKE %$name% .... What I need is following: if a query returns more then one result I what to "flip" through result with NEXT and PREVIOUS buttons.
Mysql/php - "LIMIT" And "ORDER"
In the following fragment of code, I am querying a database that in order to display a list of films. The list is very long and I would like to offer the possbility to restrain the range of results showned by page keeping in mind that the user should be able to browse forward or backward data if applicable. I know that I have to add the LIMIT method in the MySQL query but I have a hard time figuring how not to get lost in setting it dynamically in the PHP script. Then I have a second question. Is there a more elegant / straightforward way to deal with the display order of the data (cf. $ot, $od and $oy)? Code:
Sticking "if" Or Changes Within A MySQL "where" Array?
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit, you'll see a lot of results. And I have HR's dividing each entry. What I need to do is group all the entries of the same year, or at least only put HR's between the blocks of years. So, I'd have all the entries for 2002, an HR, then all for 2001, an HR, etc. Here at the bottom I'll include my PHP code I'm using so far. But I have no idea where to even start looking for an answer...if it's even possible. If someone can just give me the name of the function or process or technique, then I can go Web/book searching myself...I just need a direction of where to go. PHP:------------------------------------------------------------------------ ------ $query_RS_award = "SELECT * FROM $award WHERE id != Ƈ' ORDER BY year DESC, w DESC"; //$query_RS_award = "SELECT * FROM $award WHERE year = "$year""; $RS_award = @mysql_query($query_RS_award, $connection) or die("Couldn't query: " . mysql_error()); $totalRows_RS1 = mysql_num_rows($RS_award); while ($row_RS_award = mysql_fetch_assoc($RS_award)) { $award_id = $row_RS_award['id']; $award_tblid = $row_RS_award['tblid']; $award_award = $row_RS_award['award']; $award_year = $row_RS_award['year']; $award_category = $row_RS_award['category']; $award_won = $row_RS_award['w']; $award_film = $row_RS_award['film']; $award_nominee = $row_RS_award['nominee']; $award_note = $row_RS_award['note']; if (!($award_category)) { $award_category = "n/a"; } else { $award_category = $award_category; } if ($award_won == "1") { $award_won = " - Award Winner"; } else { $award_won = ""; } $display_block_Award .= "YEAR: <span class='normalText12White'>$award_year</span><br>FILM: <span class='normalText12White'>$award_film</span><br>CATEGORY: <span class='normalText12White'>$award_category</span><br>NOMINEE: <span class='normalText12White'>$award_nominee</span><span class='normalText12BoldWhite'>$award_won</span><br><blockquote><span class='normalText12White'>$award_note</span></blockquote><hr>"; }
Cookies And "include" Or "require"
i'm having a problem with my setcookie() instructions. Although there are absolutely no html tags in front of them,for some reason PHP3 sends me back the message "oops...php3_SetCookie called after header has been sent"... I do however use two "require" calls, one to a file with a .php extension, and one to a file with an .inc extension. At the beginning of each files there's a Could the cookie failure and the include functions be related ? In my text, I have even wiped out any HTML tags such as "bold, paragraph, line break" tags, even in "echo" commands, but to no avail what am i doing wrong ?
FTP_login + $pass="" And $user=""
I use the following scrit in an Intranet with the user name = "" and the password = "" : <?php $ftp_server = "192.168.25.25"; $ftp_user = ""; $ftp_pass = ""; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected at $ftp_user@$ftp_server "; } else { echo "Can't connect with $ftp_user "; } ?> I have the following message : Connected to 192.168.25.25 Warning: ftp_login(): 'USER': Invalid number of parameters in E:www est_ftp.php on line 26 I tried to : ftp_login($conn_id, "", "") but i have the same result...
Why Use "Stripslashes" And "Addslashes" Function
Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...
Parse Errors With "case "action":
I want to call an action that is in a file called "configm.php" but I get a parse error on line 8. (the bit that goes 'case "add":') Code:
How To Count "Hit" And "View"
I would like to know when a user logs in, he clicks Mike's E-mail. It will count one which mean "Hit". So that I will be able to know how many times users click Mike's E-mail. Like Sitepoint. When other users read other problems. Views will count 1. I would like to know how to do it. Could you explain with script?
"echo" Or "print" ?
Can tell me someone is some big different between "echo" and "print". What You prefer to use?
Make "blabla" Into Keywords As In "php.net/blabla"
I know this must be documented, but I cant seem to find it. How would you transform the URL into values? Like how php.net does; www.php.net/date does a search for "date" in their database... I have built a simple search function on my site, and I would like to do the same.. anyone who knows how? Or who has seen an article in the subject? Or has any other tips?
Error Using Header("", FALSE) To Show Multiple Images From MySQL Db
Many people seems to have problems when displaying multiple images from their database (mySQL db). Often you can read error statements like "Header already sent out ...". To solve this, people often propose to use include files. To keep the scipt it would be nice not having this problem, being able to sent out multiple headers to a browser without getting these error messages. In the PHP4 manual, we can read an option that can be added to the header statement, Header("xxx",FALSE). It would enable multiple headers to be sent out. For instance the following statement: while ($product = db_fetch_object($result)) { header("Content-type: pv($product->filetype)",false); echo pv($product->image)" } However, it doesn't work. Anybody has any idea why? Does anybody use this option FALSE with success?
Reading An Array Of Records From MYSQL Then "Save As" Them Back As Copy
Hi all, Ok here is what I want to do then I will show you what I have. I have some records in a MySQL DB that I want to store in an array and then immediately copy them back where the only thing that would change would be one field - the date. So here is my table: ------------------------------------- |userName | date | value | -------------------------------------- | theDano | 200005 | 123 | -------------------------------------- | theDano | 200005 | 345 | -------------------------------------- | theDano | 200004 | 678 | -------------------------------------- | joeUser | 199908 | 897 | --------------------------------------- So if I am querying for the user "theDano" on a specific date (format yyyymm) in this case 200005 (year 2000 month of May) Here is my array to query all records to fullfill this request: if ($update=="future") { if ($month!="01") { $db = mysql_connect("localhost", "dbuser"); if($db) { mysql_select_db("dbName",$db); $result = mysql_query("SELECT * FROM tableName WHERE userName = '$userName' AND date = '$date' ORDER BY value DESC ",$db); if ($result) { $num=mysql_numrows($result); $i=0; while($i < $num) { $userName = mysql_result($result,$i,"userName"); $value = mysql_result($result,$i,"value"); echo "<tr>"; echo "<td width=Ê×'>" . $userName . "</td>"; echo "<td width=ï`'><div align='right'>" . $value . "</div></td>"; echo "</tr>"; ++$i; } } } } } Now I want to take the array of records queried which was: | theDano | 200005 | 123 | -------------------------------------- | theDano | 200005 | 345 | and copy them to look like this back into the database: | theDano | 200006 | 123 | -------------------------------------- | theDano | 200006 | 345 | so you can see that the only thing changed was increasing the month by one. Would seem simple to most but I am having a tough time wirting the code to read the array and increase each date value by "1". Thank you in advance for anyone that replies. ) Dano
Bizarre Phantom Bug (Calling A PHP Script From An Apache "Action" Directive)
I am using an "Action" directive in my Apache configuration to map a certain file type (by means of AddType and AddHandler) to a PHP script. I wasn't sure if this would work, since the Apache docs say the Action directive is for mapping a handler name to a CGI script in particular. But it seemed to work at first. Then a mysterious bug arose: Sometimes it works perfectly, and other times the output is a totally blank page. It seems that if I haven't viewed a page for a while, it chooses to do one of these at random (though it is blank more often than not), and then it persists in the same behaviour until I reload it many times. (That is, usually a page appearing blank will eventually display if I reload it many times; however, only rarely will a correctly-displayed page regress to appearing blank after reloads.) Checking with `curl -i', it would appear to a client program that the request was perfectly successful: all the headers are there (with the correct content-type), it has an HTTP/1.1 200 OK line, and so on (and there's nothing unusual in the server's access or error logs), except Content-length is 0, and there is indeed no content at all after the two newlines. WTF?? Since when do computers behave non-deterministically? I should hope, if a program is not going to behave correctly, that it at least do so predictably and consistently. That would make debugging it much easier. But what am I to make of this Schrodinger's Bug? How do I even approach the debugging process? (Also, if anyone could suggest a workaround, an alternate method of having a PHP script handle files with a certain extension, then that would be just as welcome. Though I'd like to stay within mod_php, avoiding a CGI-based technique, because I'd prefer to not start a process every time these pages are requested.)
|