php

PHP header() redirect not working after shortening URL using bit.ly

Hi, I have a problem with php header redirect. I already spent hours trying to fix it. The problem doesn't occur when the bit.ly api is not used in the script, I have no clue why. <?php if (strlen($_GET['url']) > 26) { $shortenedURL = $_GET['url']; if (isset($_GET['login']) && isset($_GET['apikey'])) { $s...

getframe from swf with php\js

How i can getframe from swf and save as jpeg\png ...

Why can't the w3c validator load Perl's SGML::Parser::OpenSP?

I have installed W3C validator locally on Windows, following their instructions. I am getting this error while validating a site: Can't locate loadable object for module SGML::Parser::OpenSP in @INC (@INC contains: C:/www/perl/site/lib C:/www/perl/lib .) at C:/www/validator/httpd/cgi-bin/check line 60 Compilation failed in require...

is there a native php function to see if one array of values is in another array?

Is there a better method than loop with strpos()? Not i'm looking for partial matches and not an in_array() type method. example needle and haystack and desired return: $needles[0] = 'naan bread'; $needles[1] = 'cheesestrings'; $needles[2] = 'risotto'; $needles[3] = 'cake'; $haystack[0] = 'bread'; $haystack[1] = 'wine'; $haystack[2] ...

Build associative array based on values of another associative array

I'm looking for an elegant way to turn this array: Array ( [foo] => 1 [bar] => 1 [zim] => 3 [dib] => 6 [gir] => 1 [gaz] => 3 ) Into this array: Array ( [1] => Array ( foo, bar, gir ), [3] => Array ( zim, gaz ), [6] => Array ( dib ) ) Note:, there is no relationship between the keys or values. They are completely a...

PHP unit tests for controller returns no errors and no success message.

I'm using the zend modular director structure, i.e. application modules users controllers . . lessons reports blog I have a unit test for a controller in 'blog' that goes something like the below section of code: I'm definitely doing somet...

php how to serialize array of objects?

Hello, I have small class called 'Call' and I need to store these calls into a flat file. I've made another class called 'CallStorage' which contains an array where I put these calls into. My problem is that I would like to store this array to disk so I could later read it back and get the calls from that array. I've tried to achieve ...

Why would some $_POST variables go missing for a form with PHP?

Sometimes, multiple times a day in fact, users of my web application are submitting a certain form which has about a dozen form fields, half of which are hidden fields, and half of the $_POST data is simply not present in the processing script. Note that the fields that are not present are at the very bottom of the form. I know this beca...

special characters in "file_exists" problem (php)

I use special characters (swedish letters åäö). Now, I have some folders, which contains images for classifieds. The folders are named by category. for ($i=1; $i<=5; $i++){ if (file_exists($big_images.$i.'.jpg')){ echo "Inne"; unlink($big_images.$i.'.jpg'); } if (file_exists($thumb_images.$i.'.jpg')){ unlink...

drupal rules module - add fields to email

I am looking for the syntax to add node fields to the body of an email. Examples I looked at indicate the the format is: [content_type:content_type_title] However my email arrives with just the string : [content_type:content_type_title] Even better would be a PHP snippet that loads the node and dumps filed title and filed value int...

PHP Exceptions in Classes

I'm writing a web application (PHP) for my friend and have decided to use my limited OOP training from Java. My question is what is the best way to note in my class/application that specific critical things failed without actually breaking my page. Currently my problem is I have an Object "SummerCamper" which takes a camper_id as it's ...

Customizable Windows right-click file uploader for CMS?

I'm looking for a "right-click upload" application like RightLoad - an application that can upload media files to a remote FTP server from the Windows Explorer's context menu. I want to customize the application to serve as a customized image uploading tool to a PHP-based CMS. The user would upload images and other media files to a def...

Problems with MYSQL database

I edited the code and now the page loads and everything, but it does not insert into the database: <body> <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { require("serverInfo.php"); mysql_query("UPDATE `cardLists` SET `AmountLeft` = `AmountLeft` + ".mysql_real_escape_string($_POST['Add'])." WHERE `cardID` = '".mysql_real_escape_...

Use PHP to create thumbnails. (Cropped to square)

I have a php script im currently using that creates thumbnails based on a max width and height. However, I'd like it to always create square images and crop the images when needed. Here is what I'm using now: function makeThumb( $filename, $type ) { global $max_width, $max_height; if ( $type == 'jpg' ) { $src = imagecreat...

How do I pass a multi-dimensional array as a GET parameter in PHP?

I have the following code. $connect = new Connection (); $response = $connect->putFile($fileName, $destination); header("Location: /test.php?response=" . $response); When I invoke header with the response, the file will stop execution, but I will have no error in the console... I am thinking maybe this array needs to be encoded for ...

php cURL or file_get_content affect on google analytics

Im wondering what affect loading an external page with php has on a sites analytics. If php is loading an external page, and not an actual browser, will the javascript that reports back to google analytics register the page load as a hit? ...

Update category's parent via script wp_update_category() ?

I have several categories in which I need to update/assign the parent category so that the default category (uncategorized) becomes the parent. Its very easy to do this via the category manager, however, I need to do this via script. ...

PHP: how to mark a radio button as checked on pageload?

I'm looking for an attribute like checked="checked" for checkboxes which i can echo out in php.. ...

cleaner php code

if (isset($_GET['sort_by']) && strlen($_GET['sort_by']) > 0) { $sort_by = $_GET['sort_by']; } else { $sort_by = 'desc'; } how can I rewrite that so it looks cleaner and has less lines.. I love one liners hehe ...

Php using unserialize() and serialize() changing values in a saved file

I have a serialized array of values saved to a file and need to change the value of one of the variables. In the example I change the value of $two and then save the whole array back into the file with the new value. Is there a more efficient way of altering just the single value with out having to read and write the entire file/array. ...