php

set background color for php gdlib imagerotate and imagecopy

I'm using PHP 5 GD Lib to do some graphic manipulations, and I can't find a way to get around the black background that shows up when you rotate an image or copy an image to another (larger) image. Assuming that I am working with a jpeg file, which of course is not transparent, how can I rotate the image using gd lib and end up with a ...

Looking for a PHP cart that can update pricing with a Web Service

Our company wants to resell products that change in price quickly. Our wholesaler offers a web service that we can call to get the current price of any item at any time. We would like to call this web service before displaying the product page to the user. (It would be bad for us if we sold a bunch of memory just after a large price i...

Inherited a PHP nightmare, where to start?

I've inherited a PHP project that's turning out to be a nightmare. Here are the salient points: All the original developers have left The code has no version control All development and testing was done on the live server by renaming and editing the PHP files. There are multiple copies of each file index.php, index2.php, index3.php etc...

Redirect to specified URL on PHP script completion?

How can I get a PHP function go to a specific website when it is done running? For example: <?php SOMETHING DONE GOTO(http://example.com/thankyou.php); ?> I know this is really simple, but I am just having a hard time finding it on the interweb! Update: I guess I should have mentioned this. I would really like the following... <...

automatic htaccess login - multiple protected dirs accessed from one login

I am trying to make a php login page that allows users to access multiple .htaccess protected pages (on apache server). So a user would enter a password in a form on page 1 and depending on which login they provided, they would be sent to one directory or another, but I want the login to happen automatically to the subsequent pages (log...

Convert US date format to ANSI SQL date format (YYYY-mm-dd)

I want to convert user-submitted date format (mm/dd/yyyy) to a MySQL date format (YYYY-mm-dd). Submission is via a simple PHP form direc tto MySQL database. ...

Sorting an Array of Objects in PHP In a Specific Order

I have two arrays in PHP. The first array ($author_array) is comprised of user_ids in a particular order, like so: (8, 1, 6) The second array ($user_results) is comprised of an array of objects like so: Array ( [0] => stdClass Object ( [ID] => 1 [user_login] => user1 ) [1] => stdClass Obj...

Posting feeds in facebook, can't use the API.

I'm getting a "Call to undefined method" when I try to use feed API functions like registerBundleTemplates and feed_publishUserAction. Google has led me to believe that I need to call a function called useBetaApiServer, but I can't find any example on how to call it with PHP. Any help? ...

Caching HTML output with PHP

Hi! I would like to create a cache for my php pages on my site. I did find too many solutions but what I want is a script which can generate an HTML page from my database ex: I have a page for categories which grabs all the categories from the DB, so the script should be able to generate an HTML page of the sort: my-categories.html. the...

JavaScript function not responsive

Hello, I have the following code, which is the core part of my small AJAX application. I am not getting any errors, it is just that nothing happens. I am guessing there is a more efficient way to do what I am trying to do. Here is the code: var xmlHttp var layername function update(layer, part, pk, query) { if (part=="1") { $url...

php and mysql searching and passing variables problem

Hello, I have the following code: http://www.nomorepasting.com/getpaste.php?pasteid=22615 Which is called by the javascript mentioned in this question: My problem is that I do not seem to be able to pass $query, as in nothing seemingly happens when I call this file by itself. I am unsure what the best way to control the flow of info...

conditional logic with php

Hello, I have the following code: <?php if (isset($_GET["cmd"])) $cmd = $_GET["cmd"]; else die("You should have a 'cmd' parameter in your URL"); $pk = $_GET["pk"]; $con = mysql_connect("localhost","x","geheim"); if(!$con) { die('Connection failed because of' .mysql_error()); } mysql_select_db("ebay",$con); if($cmd=="Ge...

MySQL and PHP unicode problems

Hello, I have the following UTF-8 file exported from a microsoft access file http://www.yousendit.com/download/TTZtT214SU84Q1FLSkE9PQ I have ensured my mysql database is utf8 with the status; command for both client and server. I insert the above file into my database with the following command: LOAD DATA LOCAL INFILE 'tblAuction1.tx...

Can I extend a class using more than 1 class in PHP?

If I have several classes with functions that I need but want to store separately for organisation, can I extend a class to have both? i.e. class a extends b extends c edit: I know how to extend classes one at a time, but I'm looking for a method to instantly extend a class using multiple base classes - AFAIK you can't do this in PHP b...

booleans with PHP

Dup of http://stackoverflow.com/questions/330709/some-basic-php-questions#330829 Hello, I have a heap of tinyint fields in a mysql database I need to show with PHP. At the moment I am doing something like this: if ($row['PAYPAL_ACCEPT'] == "1"){ $paypal = "Yes"; else $paypal = "No"; } For each field, which is tedious and seems l...

PHP - Query single value per iteration or fetch all at start and retrieve from array?

I have a function that looks something like this: //iteration over scales foreach ($surveyScales as $scale) { $surveyItems = $scale->findDependentRowset('SurveyItems'); //nested iteration over items in scale foreach ($surveyItems as $item) { //retrieve a single value from a result table and do some stuff ...

Default Number of Decimal Places to Output in PHP

Hi all, I do my php work on my dev box at home, where I've got a rudimentary LAMP setup. When I look at my website on my home box, any numbers I echo are automatically truncated to the least required precision. Eg 2 is echoed as 2, 2.2000 is echoed as 2.2. On the production box, all the numbers are echoed with at least one unnecessar...

PHP/mySQL - how to fetch nested rows into multidimensinal array

Coming from another question of mine where I learnt not to EVER use db queries within loops I consequently have to learn how to fetch all the data in a convenient way before I loop through it. Let's say I have two tables 'scales' and 'items'. Each item in items belongs to one scale in scales and is linked with a foreign key (scaleID). I...

Continue running a php script after page is returned

I'm trying to write a script that will create a file on the server then use header() to redirect the user to that file. Then, after about 10 seconds I want to delete the file. I've tried this: header('Location: '.$url); flush(); sleep(10); unlink($url); But the browser just waits for the script to complete then gets redirected, but th...

Caching always loading files in PHP

In my index.php file I always load some classes used later in code. From profiler it states it sometimes can take about 20% of entire code. Is there any impovement that can make this process faster? I would try to make this list of classes shorter, but app is very big and checking all dependencies will be costly. ...