php

PHP: how do I convert a non-truecolor image to a truecolor image?

How to do that with GD? ...

PHP Regex remove unwanted data

Hi All I would like to be able to remove content from a string of data. This is an example string from google maps api. Distance: 70.5&#160;mi (about 1 hour 12 mins)<br/>Map data &#169;2009 Google I would like everything in between the brackets (). So can I remove everything from either side with preg_split ? Hope you can advise. ...

simple regex help php

Hi, I have a string Like this: MyText (1,151) I would like to get with regex only the value inside (), in this case only: 1,151. I know it is simple but I am not good with regex. Thanks! ...

Problems installing pear package (Failed loading /usr/lib64/php4/php_ioncube_loader_lin_4.3_x86_64.so)

Trying to install pear package and keep getting this strange error. Can you shed any light on it? Failed loading /usr/lib64/php4/php_ioncube_loader_lin_4.3_x86_64.so: /usr/lib64/php4/php_ioncube_loader_lin_4.3_x86_64.so: cannot open shared object file: No such file or directory Full message: root@www webapps]# pear install --alldeps...

SPL Throwing Exceptions

Is there a way to throw exceptions from an SPL Autoloader in PHP in case it fails? It doesn't seem to work under PHP 5.2.11. class SPLAutoLoader{ public static function autoloadDomain($className) { if(file_exists('test/'.$className.'.class.php')){ require_once('test/'.$className.'.class.php'); return...

Authentication in headers through credentials instead of cookie

Hello, I am accessing a url which needs authentication, so for authentication i am using cookie something like this $out = "GET $path HTTP/1.0\r\nHost: $host\r\nCookie: user=$cookie\r\n\r\n"; $fp = fsockopen($host, 80, $errno, $errstr, 30) or htmlerror('Bandwidth limit exceeded, please try again later.'); fwrite($fp, $out); so i want...

PHP Always run function

I am trying to get some errors returned in JSON format. So, I made a class level var: public $errors = Array(); So, lower down in the script, different functions might return an error, and add their error to the $errors array. But, I have to use return; in some places to stop the script after an error occurs. So, when I do that, ...

Passing query string to JS window.open in IE7 doesn't work?

I can run the following via the address bar in Firefox just fine: javascript:window.open("http://my.hostname.com/test.php?id=12345", "exportWindow"); When I print_r($_GET), I see the $_GET array with the values I specified in the URL. But when I do so in IE7, it just prints "null" on screen. EDIT Turns out that was due to a popup bl...

Create image Thumbnails before or after upload the best way?

Hi. Imagine you have a classifieds website... When searching ads you want image thumbnails of the "real" image which displays in its real size after clicking the ad... Would it be faster to create the thumbnails per search, or create the thumbnails on and then just display them? Storage is not a problem on my server... Thanks ...

Web based method to determine if an iPhone is connected via 3G or Wifi

I'm in the process of building a webapp that allows users to view a video podcast. At present, the user can select whether they would like low or high bandwidth videos depending on whether they are connected via 3G or Wifi. Is there any way that a webapp could determine this? I know of one way that could use the IP of the device to dete...

Having problems changing the font in a table row

This doesnt work: $display_table .= "<td width='377' height='15' class='ad_headline_font'>$row[headline]</td>"; It shows the 'headline' From a mysql field but in standard text... why cant i format the text? And the table doesnt have a class appointed to it... and style= doesnt work either... Thanks the css style: .ad_headline_font...

BLOB Download Truncated at 1 MB Script Works for Files Less Than 1 MB

I just recently asked and solved a question pertaining to uploading .PDF files that are greater than 2 MB into a MySQL database as BLOBS. I had to change some settings in my php.ini file and MySQLs maximum packet setting. However, fixing this issue has led me to discover a new issue with my script. Now since I can upload files to my ...

PHP, mysqli, and table locks?

I have a database table where I need to pull a row, test user input for a match, then update the row to identify the user that made the match. Should a race condition occur, I need to ensure that the first user's update is not overwritten by another user. To accomplish this I intend to: 1. Read row 2. Lock table 3. Read row again and c...

Modify Array to Output in JSON using PHP and jQuery

Hello, I'm currently working with the jQuery Autocomplete Plugin. The code they provided in the demonstration is: <?php $q = strtolower($_GET["q"]); $items = array( "Peter Pan"=>"[email protected]", "Molly"=>"[email protected]", ); $result = array(); foreach ($items as $key) { if (strpos(strtolower($key), $q) !== false) { a...

changed object after storage or object-state used

Example: class UserStorage { public function addUser(User $user) { //saves to db } } class User { public function setName($name); } What if I add a user to the user storage and later change that user object? In this case you might argue that user objects only should be stored on __destruct. But sometimes this isn't an option ...

PHP File upload to memory

I would like to upload a file from an html form, post it to PHP and load it into memory, bypassing writing it to a file. Is it possible to do a file upload and keep it in memory, or do I have to write it to a file? ...

Java-like Collections in PHP

I'm learning PHP5 (last time I checked PHP was in PHP4 days) and I'm glad to see that PHP5 OO is more Java-alike than the PHP4 one but there's still an issue that makes me feel quite unconfortable because of my Java background : ARRAYS. I'm reading "Proffesional PHP6" (Wrox) and It shows its own Collection implementation. I've found ot...

Mixing Python web platforms PHP, e.g. - Mediawiki, Wordpress, etc.

Is anyone developing application integrated with Mediawiki - using Django or other Python web development platforms using mod_wsgi? Would be very interested to find out what has been done in this direction and maybe there is some code available for re-use. (I've started creating wiki extensions working with MW database in python whose ...

plugin_action_links not working in WordPress 2.8+

I developed a plugin with Settings link that was working fine in WordPress 2.7. Version 2.8 brings some additional security features that cause Settings link displaying message: You do not have sufficient permissions to access this page. This is the API hook I use to create link: function folksr_plugin_action($links, $file) { if (s...

I am trying to do an ASP like repeater in PHP.

<?php $dbhost = 'xxxx'; $dbuser = 'xxxx'; $dbpass = 'xxxx'; $dbname = 'xxxx'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $result = mysql_query("SELECT * FROM mytable"); $row = mysql_fetch_array($result) ?> <?php foreach ($rows as $row): ?> <tr align="center"> ...