php4

PHP: include file relative to calling file NOT root file?

OK say I have a file called fileA.php in the same directory I have another file called fileB.php so inside fileA there is this require_once('fileB.php') notice I did not specify a file path because both files are in the same directory. Now if fileA is included into another file that is located somewhere else, it fails to include fileB ...

How to make a singleton in PHP4?

How do I make a singleton in PHP4? Is static available in PHP4? HELP!!!!!!!!!!!!!! ...

Function to create objects?

Is there a function I can use to instantiate an object with arguments? #include <database.h> class database { function __construct($dbhost, $user, $pass, $etc) { /* etc */ } function query($sql) { /* dowork*/ } } $args = array('localhost', 'user', 'pass', 'etc'); $db = create_object('database', $args); // is there a function li...

Process an array in a function, with external formatting

I want to pass an array to a function and iterate through it in this function. But I would like to be able to change the way the single entries are displayed. Suppose I have an array of complicated objects: $items = array($one, $two, $three); Right now I do: $entries = array(); foreach($items as $item) { $entries[] = create_li($...

Should there be something like 'bytelen' (along with 'strlen')?

In my opinion the 'strlen' function should only return the number of characters in a string. Nothing else. And it does, whether it counts ASCII characters or Unicode characters. A character is a character, pointing to a given position on an ASCII table or a UTF-8 table. Nothing more. If you would like to know, for whatever reason, the b...

PHP4 HTTP Post without cURL

I have the following code that works on PHP5 to send a HTTP POST without using cURL. I would like this to work on PHP 4.3.0 and above: $opts = array('http' => array( 'method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Type: application/json\r\n", 'content' => $q...

How should i properly add key => val pair to an existing array

Tried examples from 'php.net' but don't understand what's the problem. Any suggestions ? <?php $_SESSION['test'] = array('a' => '1', 'b' => '2'); foreach ($_SESSION['test'] as $key => $val) echo "key: " . $key . " val: " . $val . "\n"; // Parse error array_push($_SESSION['test']['c'] => '3'); // Parse error $_SESSION['test'][] ...

Creating an URL without global variables

I have a code like this below, which gives me a $link that equals to: http://mydomain.com/image/photo.JPG if (!empty($_SESSION['item'][$i])) { $path = dirname(__FILE__).'/image/'.basename($_SESSION['item'][$i]); if (move_uploaded_file($_SESSION['item'][$i], $path)) global $url; if ( $url ) { $link = $ur...

GD DLL installation

I'm using the JpGraph library(PHP graphing Lib). I'm getting the foll error: "JpGraph Error Your PHP installation does not seem to have the required GD 2.x library enabled. Please see the PHP documentation, "Image" section. Make sure that "php_gd2.dll" statement is uncomment in the [modules] section in the php.ini file" I uncommented t...

Do PHP 4.4.9 based applications run on PHP 5.2.0 flawlessly?

I need to change upgrade the PHP version to at least 5.2.0 for my new magento OS Commerce installation, but would it mess up my current store which runs on 4.4.9 (PHPCart)? The real question is, can I upgrade without harming the old cart? ...

Reliable strtotime() result for different languages

There was always a strange bug in Joomla when adding new article with back-end displayed with a language other than English (for me it's Russian). The field "Finish Publishing" started to be current date instead of "Never" equivalent in Russian. For a site in php4 finally found that strtotime function returns different results for arbi...

PHP4 including file during session

I am trying to put second language on my webpage. I decided to use different files for different languages told apart by path - language/pl/projects.ln contains Polish text, language/en/projects.ln - English. Those extensions are just to tell language files from other, the content is simple php: $lang["desc"]["fabrics"]["title"] = "MATE...

PHP4 No Error When Missing Method is Called

I have come across an annoying problem while writing some PHP4 code. I renamed the method of a class but I forgot to rename it where it was being called from. The annoying part is it was hard to track down where the problem was because no error was triggered. The script simply aborted leaving the web page partially rendered. Is it normal...

PHP write file... need help

<?php $title = $_POST['title']; $filename = $title , ".php"; $fh = fopen($filename, 'w') or die ("can't open file"); $stringData = $title; fwrite($fh, $stringData); $stringData = $blog; fwrite($fh, $stringData); fclose($fh); ?> This is only a sample. What is the correct code for that? ...

working with arrays

I currently do a query which goes through the records and forms an array. the print_r on query gives me this print_r($query) yields the following: Array ( [0] => ( [field1] => COMPLETE [field2] => UNKNOWN [field3] => Test comment ) [1] => ( [field1] => COMPLETE [field2] => UNKNOWN [field3] => comment here ) [2] => ( [field1] => COM...

why this sql not working?

I have a query public static function TestQuery( $start=0, $limit=0){ $sql = " SELECT count(*) AS total FROM db.table1 JOIN db.table2 ON table1.fieldID = {$fieldID} AND table2.assigned = 'N'"; $qry = new SQLQuery; $qry->query($sql); if($row = $qry->fetchRow()){ $total = intval($row->total); } ret...

Generating Graph with 2 Y Values from Text File

Hi all, I have remade my original post as it was terribly formatted. Basically I would like some advice / tips on how to generate a line graph with 2 Y Axis (temperature and humidity) to display some information from my text file. It is contained in a textfile called temperaturedata.txt I have included a link to one of my posts from t...

Global workaround for random non-specific include file being included?

I'm dealing with an outdated PHP4 IIS server which has odd settings and I absolutely cannot update PHP or modify any server settings. This legacy site on the server basically has subdirectories which have an includes directory so there are multiple includes directories, and in my root I do something like include 'includes/nav.php'; T...

Intern working for Indian NGO - Help with PHP 4, advising staff

Hello, For the past three months I've been working for an Indian NGO (http://sevamandir.org), doing some volunteer work in the field but also trying to improve their website, which needs a ton of work. Recently I've been trying to fix the "subscribe to newsletter" button, which is broken. I used filter_var to filter the email input,...

php not showing all images

I a writing a gallery app in php. The images are dynamically displayed through php. On each load of the page, not all images are showing. it does this randomly, on each load. I have not had this problem before, as I am new to php. My previous apps where all in perl, and I had no dynamic image display problems when using that language. ...