php

retreiving information from curl

hi ! i am retriving information from soundcloud using curl.it gives lot of information .but i want to filter it . <?php $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://api.soundcloud.com/tracks '); curl_exec($curl_handle); curl_close($curl_handle); ?> how can i filter information coming from it l...

PHP: "Call to undefined method" error when calling static method from parent

How is the correct way to call a child class method from a parent class if both are static? When I use static classes it returns the error "Call to undefined method A::multi()", however when I use non-static methods there is no problem, for example: //-------------- STATIC ------------------ class A { public static function calc($a...

Would using free image hosting be a viable alternative to a CDN?

Here's my situation: I'm hosting a personal website on my home desktop computer. I expect my site to have around 1000 visitors per day. The problem is that my Internet connection isn't very fast (20 mbps download, 4 mbps upload). Most of the pages on my site have around 2 MB of images. I'm thinking of uploading those images to around 10...

How to display time countdown using PHP and MySQL

How do I get a time countdown using PHP? I want to display something like 3Days 4Hours. I have a date field coming from MySQL table and want to calculate it with today's date. As of now I have only date and not the time stored in the database, but eventually I will. So at that time, I might show as 3Days 4Hours 10Minutes 43seconds. Th...

Fastest way to get random php number?

Hi I'm trying to prevent caching by appending a '? t=' to the end of my JS files. What's the fastest way to get such a number? time() or rand() or something else? ...

File+database transaction safety

I have a MySQL table which basically serves as a file index. The primary key of each record is also the name of a file in a directory on my web host. When the user wants to delete a file from the system, I want to ensure some kind of transaction safety, i.e. if something goes wrong while deleting the file the record is not erased, and i...

Why can php://input be read more than once despite the documentation saying otherwise?

The PHP documentation states that php://input can only be read once. In my application I need to read it twice, once for authentication purposes and once for actually processing the content, and both functions are handled by different, independent modules. The crazy thing is: it works. Can I count on this working everywhere, or is this...

preg_match_all question

Hey guys, For the last couple of hours i've been messing around with regex. I've never dared to lay my hands on this so please bare with me. Basicly i'm trying to get some info from the following source <random htmlcode here> <td style="BORDER-RIGHT-STYLE:none;"> <a id="dgWachtlijstFGI_ctl03_hlVolnaam" title="Klant wijzigen" cl...

Query database to get back an array

Hi guys, I need to get all of the users in my user table and then get the results as an array and traverse through it and create a XML file for each user. How would I go about doing that? I am guessing the query would be something like SELECT * FROM users but I am unsure as to how I can get all the results as an array and then how to t...

Stop PHP output buffering

Hi, I need to display continuous output from my php script. The script will stay in a loop of printing log data from a device and sleeping. My problem is that I can't get PHP or Apache to output data before the script is completed. I have tried all the commands for flushing the output buffer, and I have read through the config-files for...

When insert current time to db, which way is better?

I want to update the update_date field in oracle db. I have two ways to do it. Which one is the better? 1.$now = date('Y-m-d H:i:s'); 2.$now = "TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS')"; ...

how can I sort an array in php ?

Example : $a [] = array ('google','bing','yahoo'); $a [] = array ('America','France','Germany'); $a [] = array ('Africa','Asia','Europe'); And I want to sort her in table like that : Africa....... America........ google....... ...

Headers for MSOffice 2007 / 97 Download with PHP

We're trying to send uploaded attachements (served from a database as blob) through php with Zend Framework to a client. This code works fine for Excel97 / Word97. if ($this->getResponse()->canSendHeaders(false)) { $response = $this->getResponse(); $response->setHeader('Pragma', 'public', true) ...

Simultaneous connections on Apache

Hi, So, it seems that when a client makes more than 1 connection to the web server ( Windows + Apache 2.0.x + PHP 5.1.6 ) it dies. e.g. I put 1 phpthumb call - e.g. <img src="/library/classes/3rdparty/phpthumb/phpThumb.php?src=/media/images/gallery/cart1.jpg&w=100&h=100" /> That works. But if I put like 3 on the page, it just loa...

Shortcut to testing PHP code

Having a python interpreter is really useful as it lets you quickly type in few commands and verify output; making it easier to understand syntax. However, in PHP, every time I want to try something out I have to - create a PHP script, save it, run it in my browser. Is there a shortcut that I am missing out on for PHP that would make ...

Not able to update word/rels/document.xml.rels using PHP ZipArchive

I am trying to load binary data as images into Word documents (Opem XML) using PHP for later usage with XSLT. After opening the Word document as a PHP ZipArchive, I am able to load images into the word/media folder succesfully and also update the word/document.xml file. But I am unable to update the <Relationships/> in the word/rels/doc...

PHP5.3: "Call to undefined method" error when calling invoke from class variable

I have been doing some tests (to replace old code) with the __invoke magic method and I'm not sure this is a bug or not: Lets suppose we have a class: class Calc { function __invoke($a,$b){ return $a*$b; } } The following is possible and works without any problem: $c = new Calc; $k = $c; echo $k(4,5); //outputs 20 ...

Need to know if this is possible with SQL and if so, how to do it

Here's my current query: SELECT questions.question, questions_headings.title FROM questions JOIN questions_headings ON questions.heading=questions_headings.id WHERE questions.heading IN (1,2,3) ORDER BY RANDOM() LIMIT 10 Basically, the database contains Questions for various Headings. For example: questions_headings: +----+-------+ ...

How to truncate an html text and still maintain the format, in PHP

I have text with minimal tags like 'a','b','i' etc inside it. Now i want to truncate the text to 100 chars and still want to maintian the formatting. I don;t want to strip the tags off from the text. Is it possible? how can it be done. ...

Project Management Script?

Possible Duplicate: What Project Management Software should I use? I need a free "Project Management" script like, Codeplex or Google Code.. Futures should be: Home page issue tracking wiki Download section EDIT: Actually, I'm not asking for "tool" or "Project Hosting".. I need to host it on my server. ...