php4

PHP - highlighting search terms

I have a case where I'm returning database results and displaying them on a page based on a search term. This part is working fine, but I want to hightlight these search terms by wrapping them in span tags. I started to write a function that I called on each result that used the str_replace function, but then it dawned on me that this ...

Best way to implement try catch in php4

What is the closest you can get to a try-catch block in php4? I'm in the middle of a callback during an xmlrpc request and it's required to return a specifically structured array no matter what. I have to error check all accesses to external resources, resulting in a deep stack of nested if-else blocks, ugly. ...

Migrating php4/mysql4 to php5/mysql5: expected php issues?

I have a legacy web application php4/mysql4 (MyISAM, db contains some cms, some user data, some calendar application). Now I am going to migrate to a new server with php5/mysql5. What are the typical php issues in such a migration scenary (php, sql queries, anything)? I've heard that the function parameter passing changed, call-by-refe...

PHP: Saving files with PHP to different root directory?

OK when I save uploaded files with PHP via move_uploaded_file() I cannot use an absolute URL I have to use a relative one. My site has 2 root directories one for the http side and one for the https side: httpdocs and httpsdocs respectively. So if my script is on the https side how can I save the file to a location on the http side? Than...

PHP: How can I find out the date of the day before a date?

I have a system that compares fiscal year up to the current date to the same date range of the year before. You can adjust the year and month to look at and it always compares the same date range to the year previous. I have it set so if the current day is leap day it compares to the 28th of last year, and if last year was leap year and ...

Is there a way to do parameterized queries in PHP 4 when using a MSSQL database?

I am doing some maintenance work on an older system that is running PHP 4 and talks to a MS SQL2000 database via FreeTDS. I know, it already sounds somewhat scary! A lot of the code used unsafe string-concatenation for generating SQL queries. I have done some work to try and filter the input to make things safer but it is giving me a ...

Hunting for PHP5 incompatibilities. >.>

Something in here is incompatible with PHP5, but I am totally lost as to what. I have an .htaccess file on my web server that has the line "AddHandler x-mapp-php5 .php", as it is required by just about everything else on the server and it defaults to PHP4...however; I need this one script to work, but it only works on PHP4. Any idea wher...

PHP: Tell if a file exists?

I need to be able to tell if an image exists in a directory or not. Given the file name and the directory, how can I tell if it exists? Thanks! ...

Is there anyway to upgrade PHP4 mysql client?

I get the following error: Client does not support authentication protocol requested by server; consider upgrading MySQL client I know I can solve it with: SET PASSWORD FOR user@localhost = OLD_PASSWORD('password'); But I want to know if there is another way to do it by using a different PHP mysql extension or something? ...

PHP: how to load file from different server as string?

I am trying to load an XML file from a different domain name as a string. All I want is an array of the text within the < title >< /title > tags of the xml file, so I am thinking since I am using php4 the easiest way would be to do a regex on it to get them. Can someone explain how to load the XML as a string? Thanks! ...

PHP: Get array of text from perticular XML node type?

I am not totally new to PHP or XML but I am 100% new to paring XML with PHP. I have an XML string that has several nodes but the only ones I am insterested in are the < keyword > nodes which there are an uncertain number of each containing a phrase like so: < keyword >blue diamond jewelry< /keyword > for example say the string looked lik...

PHP: keep track of requests by user and by product brand?

I have a MySQL table that has price requests in it, it has date, first, last, and product_id fields. The product brand can be found from the product table from the product_id. Given a date range, they want to know the total number of requests, by people and by brand for each day in the date range, and total for date range. Here is the t...

PHP: how to create and ftp a file to another server?

We are setting up a drop-ship agreement with a vendor to where we don't have to stock their products we just sell them and they ship them out. To inform them of an order they want us to FTP upload a tab delimited .txt file with the order info to their site. We want to automate this. So given the user/pass for the ftp is there a way to cr...

securely send data from one site to another?

I am going to post some data from one website to another website. I need a way for the receiving website to be sure that the data was sent from the sending website and not sent by some other malicious user. I am using PHP4. How can I do this? Thanks! ...

Best practice for using fopen() or file_get_contents() to retreive web pages.

I am looking for some advice on the best way to retrieve information from a web page (my own site) and then search through that information to find a certain text. Keeping in mind that some of the servers that run PHP/Joomla do not have cURL enabled, I don't want to cause any unexpected errors. I've looked at both fopen() and file_get_...

How backwards compatible is php 5 with php 4?

Hello everyone, I work on a code base written in php 4. I'd like to go through the process of upgrading the code to php 5 (the latest version my host provides). I'm wondering if anyone else has gone through a similar upgrade experience and can share what gotchas/pitfalls there are, what has to change in my code, what is not backwards co...

Strange behaviour migrating sessions with callbacks from php4 to php5

I have to migrate a php4 app that uses session_set_save_handler() to php5. In php4 everything was fine, but in php5 the callback functions cannot access the global vars anymore, which were set on the page before session_set_save_handler() was called. In the example below the global var $g1 cannot be accessed in the session_writer() (wh...

MySQL: How many minutes ago was DB updated?

I need to keep a field in a data-base and update it with a time somehow, then later I need to check that time to see if it was over 30 minutes ago or not, and if not, how minutes left until 30? I am going to be doing this with PHP+MySql can anyone tell me the simplest way to do this? Thanks!! ...

PHP Weight Algorithm

I'm wondering if this is a sufficient algorithm for finding the best value with a weighted system. Is there anything I could add to make it better? Edit: in this example I would like the probability of $object->get() returning test4 to be 4 times greater than the probability of it returning test1 (thanks acrosman) Thanks class weight...

How to change default version of PHP from 4 to 5?

My server have default php version of 4, so when I run some script saved as .php I have PHP 4. I want to change it, so I don't must use .php5 extension, I heared that there are something in .htacess. I want to run eyeOS on my server, but I don't want to change every line from .php to .php5 Help? ...