php

json_decode() returns null issues

Hey all, I've an issue with my JSON. It works returns correctly in PHP 5.3 (so I can't use json_last_error()), and it returns successfully when I copy string explicitly into json_decode (json_decode('{...}'). It only returns null in when I pass the result as a variable and I'm using php 5.2, which is what I need it for. The output come...

How to limit speed of outgoing response from php script?

How to limit speed of outgoing response from php script? So I have a script generating data in keep-alive connection. It just opens file and reads it. How to limit outgoing speed (By now i have such code) if(isset($_GET[FILE])) { $fileName = $_GET[FILE]; $file = $fileName; if (!file_exists($file)) { print('<b>ERROR:</b> p...

Redeclaring a class on update

Hey, I am having a small problem when it comes to redeclaring a class. I made an update function that calls to a remote server, gets the files/classes, and updates it on the current server. The problem is I have to use a class the has been declared already because the new class contains features that have been updated. I've been trying...

Form which generates image in real-time

Hi, I am looking to build a form which updates an image in real-time. Could someone help me out and tell me the best way to go about creating a form similar to this (languages, techniques, etc): http://www.demonplates.com/platebuilder.php Where as you enter details the image is updated accordingly. The form will send to google checkout...

textelements with transparent background php gd

Hello, i would like to create text on a transparent gif background with php and the gd library like this: http://www.gutscheinvordrucke.de/kulinarisch/candlelight-dinner.html But in my application, the text hasn't a good quality. Does anybody know the best practice like in the posted link? Here is my code to create textarea with a tra...

PHP cURL isn't storing the session cookie... How to fix this?

Hi all, I am making a class to comunicate with our company API... I'm using curl to post data and retrieve the response in json. In the last part of the code (after the class), i log the user into the server (it gives true), but when i try to connect again with curl, he says that i'm not logged! I've done a google search already and adde...

Closing MySQL Connection After Every Query

While digging through some old code put together by a former co-worker who's talents I looked up to I noticed after every query they closed the connection the MySQL server. This seems a bit odd since I've always just closed it at the end of the page and seen most people do the same. So the question is, is this the best idea in PHP/MySQ...

How can I use PHP to get the nth item in a JSON object?

Ok, so the twitter daily trends list is 20 trends long. Let's say I want to get the 7th trend on the list. Here's my longwinded way of doing it... // We want the 7th item in the array $trendArray = 7; // Get an array (?) of the latest twitter trends $jsonurl = "http://search.twitter.com/trends/daily.json"; $json = file_get_contents($js...

Longtext data type in PHP

Longtext datatype is the largest capacity(4bytes) datatype in mysql. But it is not enough to store website content page. I’ve tried several times and searched well. And I think MYSQL can able to store maximum of 16KB for Each table. So I’m not able to store all page contents into our table “PAGE”. I’m searching for how to recover this....

Facebook. Setting status using access token (offline access)

Hi. I am wondering how to set the status of a user who has allowed offline access permissions. I have the users ID and access token but can't figure out how to pass both to the function. Any ideas? ...

Which PHP Framework to integrate into existing system?

Hi, I currently work with an in-house CMS which was developed long before I joined the company. It's full of procedural spaghetti code which mixes SQL, PHP and HTML altogether, often on the same line. As you can imagine, it can get very difficult to follow and understand. I would like to integrate a mature framework in order to mak...

How do headers work with output buffering in PHP?

Title is self-explanatory. I have a good bit of experience with PHP, but I am not sure how the header function works between ob_start() and ob_end_clean(). Consider this: ob_start(); echo "Some content"; header('X-Example-Header: foo'); echo "Some more content"; $output = ob_get_contents(); ob_end_clean(); echo $output; Does the ...

Create master checkbox outside {foreach} tag

Hello, I have dynamic page under {foreach} tag something like this. <div id="c1"> {foreach} <input type="checkbox" name="checkbox" id="{$num}" checked/> {/foreach} </div> which in return prints something like this. <div id="c1"> <input type="checkbox" name="checkbox1" id="1" checked/> <input type="checkbox" name="checkbox2" id="2" c...

Why wouldn't dns_get_record show CNAMEs when I KNOW they exist?

I'm playing with DNS record lookup in PHP and am running into something confusing. I've looked up 2 different domains each using different hosts and different authoritative name servers. Both of these domains I know for certain have CNAMES. I've looked up DNS records using this online tool: http://network-tools.com/ I've also looked t...

Zend Date Weirdness - Missing Configuration?

I'm getting odd output from the getDate() function. It's supposed to return a date without the time parts, but I am getting time parts. Am I missing some configuration option that would correct this? Sample Code: date_default_timezone_set('America/New_York'); $date = new Zend_Date(array( 'year' => 2010, 'month' => 3, 'day...

What can cause a website to not always load

Roughly about 20% of the time when clicking on links in my website (www.slr-lens.co.uk), the site completely fails to load. I have tried removing and adding all code segments but to no avail... I've also asked the web hosts, but apparently the server is working normally. Does anyone have any suggestions about what could cause a web pag...

Best practices for automating creation of XML files for front-end access?

I am working on a custom PHP/MySQL CMS. The data managed in the CMS is exported to XML files via a PHP script that must be ran manually. A Flash/AS3-based front-end loads the XML files and displays the specified data. Is it advisable to setup some sort of automated process for creating the XML files? What are some "best-practices" or r...

How to find an image in an post

I've never done anything like this, so I'm not really sure what kind of tools within PHP i need to make this happen. I'm making a list of "recent news items" (just headlines) that'll show up on the side of the site, and would like to be able to look for the first image in a news post (I assume it has something to do with looking for an...

Checking if process still running?

Hello, As a way to build a poor-man's watchdog and make sure an application is restarted in case it crashes (until I figure out why), I need to write a PHP CLI script that will be run by cron every 5mn to check whether the process is still running. Based on this page, I tried the following code, but it always returns True even if I cal...

I have written custom classes for IIS, v 6.X , and they don't seem to be working

I have written a couple of custom php classes that are deployed to IIS servers. They work fine on the development box but not on the staging server. I don't have much experience with IIS and am not sure if it's a config issue with IIS or a something to do with the php.ini file. Any hints would be appreciated. Sorry for being vague. ...