php5

Move a file and rename it.

Figured PHP's rename would be my best bet. I didn't see many examples on how to use relative URLs in it though, so I kind of compromised. Either way, this give me permission denied: I want to do this: $file = "../data.csv"; rename("$file", "../history/newname.csv"); Where ../ of course would go back 1 directory from where the script ...

a question about mysql select query!

I have a list of events for example I wanna show on a page with the users that have created them which is all in a table and the user who has created them's unique id, now if I wanna show their username and avatar I would have to run 100 queries inorder to show 100 events! but I'm sure their is a easier way I don;t know! i have a table ...

PHP - linux/unix CTIME (inode change time) is being set when it's only being modified.

According to: http://www.php.net/manual/en/function.filectime.php "In most Unix filesystems, a file is considered changed when its inode data is changed; that is, when the permissions, owner, group, or other metadata from the inode is updated." However, running Debian linux (uname -r: 2.6.26-2-686) when I access and write to a file, s...

How do I prepend file to begining??

In PHP if you write to a file it will write end of that existing file. but how do we prepend a file to write in the beginning of that file?? I have tried rewind($handle) function but seems over writing if current content is larger than existing... Any Ideas?? ...

How do I write this array in simple method??

I do have a function which do calculations a lot. $arrleft and $arrright are two different arrays. what I am doing here is I am combining two to produce together output for my current application. what I done is a simple method and it eats lots of space and time. what I want is if any one can make this code to a couple of lines shorter...

PHP: How to get a Date when a person reach to a specific age?

I am working on task in which dates are involved. I have a person's age in months+days. Now I want to get a date when this person reach to a specific age in months. For example: A person is 250 months and 15 days old on 2010-1-25. On which date this person will become 300 months old? Function Signature may be: function getReqDate( ...

Need a general idea for how to communicate with server PHP script and return error information to client

Hello all, I have a form that the user needs to populate and then the form will be sent to a server. After the user submits the form, if the server script found that the form is not correctly populated (i.e. the uploading file is too big), it should return error to the client side. Now, my question is as follows: How do I keep the use...

Can PHP static methods legally have a visibilty of protected or private?

I realize that it's possible to define a static class method as private and protected in PHP. This allows for an instantiated class, or public static method to access it's own private/protected static methods. protected static function jumpOver () However I'm not sure if this is legal in the sense of OOP design. I can't find any real...

deleting last array value ? php

1 question type $transport = array('foot', 'bike', 'car', 'plane'); can i delete the plane ? is there a way ? 2 question type $transport = array('', 'bike', 'car', ''); // delate the last line $transport = array('', 'bike', 'car', 'ferrari'); // dont the last line $transport = array('ship', 'bike', 'car', 'ferrari'); // dont the...

passing URL variables to exec() with php

I have a dedicated server that I use to crunch lots of data. The way I have it now, I can open a script with a process ID like example.php?ex_pid=123 and just let it go. It downloads a small portion of data, processes it, then uploads it into a database then starts again. Ideally, I would like to call example.php?ex_pid=123 directly and...

PHP FTP Recursive download blocks with no apparent reason

Below are the functions that I use to download a FTP folder, recursively. I ran this several times, but after a successful run for like 1-2 mins, it always stops on the same spot, at the same file, generating this : ...... ...... Downloaded: login-bkg-bottom.gif Downloaded: login-bkg-tile.gif Downloaded: logo-ghost.png Downloaded: logo-...

PHP Based Web Crawler or JAVA Based Web Crawler

Hey i have some doubt about PHP based web crawlers,can it run like the java thread based one? i am asking it because, in java the thread can be executed again and again, i dont think, PHP have something like thread function, can you guys please say, which web crawler will be more use full?A PHP Based or A Java Based ...

php digital clock for london zoon

Hi How to create digital clock using PHP (london time zone) sample clock Am looking this sort of one clock, ther is a possible with ajax and php to we display similar of clock and date.. Thing is .it require too much of ajax,java script functions ...

PayPal error messages on PHP 5.3.1

Hi all, I'm integrating PayPal in an application written in PHP and running on PHP 5.3.1 (using Zend Engine 2.3.0). Every time I require a PayPal SDK file or use any of the methods it prints out an enormous amount of error and warning messages. I obviously want to keep error message reporting at the maximum level possible (at least for ...

Is there a way to set the default database handle with mysql_query?

Is there a way to set the default database handle with mysql_query? So I know that mysql_query can be called without a sql handle but then it will basically use whatever handle you got from the last mysql_connect. What if I wanted to set that default handle myself, how do I do it? I just want to make it clear that we have all our code...

Enabling a '.equals' equivalent for PHP5 Classes

Greetings, I've got two instances of a PHP5 Class (say ClassA), and I want to compare to see whether they are equal. In C#, I can write a .equals(ClassA other) method for ClassA, which will be overloaded onto the == operator. Is there an equivalent way in PHP5 to overload a method in a class and have that be used for == comparison, ...

need help with zlib!

I wanted to compress my pages so I put ob_start('ob_gzhandler'); at the beginning of my php header file. however as I was playing around I noticed it will give me a blank page if I start a session while the ob_gzhandler was not being used! so I did the below and it worked: how ever I'm not sure if this will always use the compression a...

Do I really need to do mysql_close()

Do I really need to do mysql_close()? Why or why not? Is there a trigger that closes the link after mysql_connect even if I don't do mysql_close? ...

Convert Windows-1252 csv to UTF-8 using PHP

I'm using fopen to read in a csv and fgetcsv to read the csv lines. The csv is encoded as Windows-1252, how do I convert this to UTF-8 so it doesn't cut lines with none standard characters? So far I've tried the following: setlocale(LC_ALL, 'en_GB.UTF-8'); and drupal_convert_to_utf8($csv_line[3], 'Windows-1251'); // (I'm using Drupa...

Count number of times a character appears in a url using PHP

Hello, I want to count the number of times "/" appears in this url Here is my code $url = "http://www.google.com/images/srpr/nav_logo14.png"; $url_arr = eregi(".",$url); echo count($url_arr); It displays on "1" Appreciate all help Thanks Jean ...