php

To understand a line of PHP code about a connection

What is connection() in the following code? Code which I do understand completely if($user->connection($email,$password)){ } Let's assume connection() is pseudo-code. Is the pg_prepare and pg_execute` enough to create the connection? The line caused me to omit the use of its main code in generating a login system. Subsequently, ...

Why are globals empty inside a class when the variabled are included?

What I am trying to do is have a separate PHP file containing settings for the website, and then having other pages include this file and execute code according to the settings. However, whenever I use global to reference these variables inside a class, the variables are empty. For example: settings.php: <?php $setting1 = 'on'; $settin...

Does PHP have an equivalent to Python's list comprehension syntax?

Python has syntactically sweet list comprehensions: S = [x**2 for x in range(10)] print S; [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] In PHP I would need to do some looping: $output = array(); $Nums = range(0,9); foreach ($Nums as $num) { $out[] = $num*=$num; } print_r($out); to get: Array ( [0] => 0 [1] => 1 [2] => 4 ...

PHP static variables in double quotes

Hi, How can I get PHP to evaluate a static variable in double quotes? I want to do something like this: log("self::$CLASS $METHOD entering"); I've tried all sorts of {} combos to get the variable value of self::$CLASS, but nothing has worked. I've currently settled with string concatenation but it is a pain to type: log(self::$CLA...

MySQL DATE_ADD - date is wrong?

So I've got a simple query in MySQL that sets a new member's expiration date once they pay their dues: UPDATE members SET joined=CURDATE(), expires=DATE_ADD(CURDATE(), INTERVAL 1 YEAR), active='1' WHERE id=1000 this query has run 200+ times, normally with the correct result - the current date is put in the joined field, and a year fro...

Webservices in PHP

Am a stranger to web services and I need to integrate web services into an existing application. The details to be passed to the web services are Unique reference Amount Status Status Description This web service will update the website on the status of a transaction. what is the best way to start? where do i go from here? ...

Can I create UPS package shipments/pickup requests with PHP? Sample code?

I know that UPS has some APIs they make available for doing shipping calculations. Is it possible to create a shipment and PDF shipping label using the UPS APIs with PHP? Does anyone have any working sample code? ...

Delete cookie from browser?

Is there any way of instructing a web browser to completely delete one's cookie set with PHP? I do not want to expiry it or wait for the browser to be closed. With delete I mean to actually not have it listed inside the cookie's list anymore. ...

Creating mock Objects in PHP unit

Hi, I've searched but can't quite find what I'm looking for and the manual isn't much help in this respect. I'm fairly new to unit testing, so not sure if I'm on the right track at all. Anyway, onto the question. I have a class: <?php class testClass { public function doSomething($array_of_stuff) { return Anothe...

How do you ask an external program to open a file being served through a web browser? What about detecting if the external program is installed?

Hello Folks, I have a two part question. The first I think I have an okay answer to.... I am looking to force an external program to be called up to view a configuration file for an application my company is working on. The basic gist I guess is to set the Content-type header to type that your application is associating with, and then ...

Zend Framework career path tricks

I am a seasoned PHP developer (writing custom apps, templates, CMS, js), but only recently I dived into the world of frameworks like Zend Framework or Cake PHP. The trick is that I am working from home, which means Joomla or Drupal job is easy to find, even if you're a newbie. Which doesn't seem to be the case with ZF, per my initial mar...

HTTP 500 error on IE7

For my development environment I recently moved to PHP 5.3 w/ fastCGI on IIS from php 5.2 w/ ISAPI on IIS and when I have an error (such as function name is incorrect) I'm used to PHP reporting back FATAL ERROR etc... to the browser. Intermittently instead of receiving the error I receive a HTTP 500. If browsing with firefox this does ...

How would I add a PHP statement to conditionally subtract?

I have a form that uses PHP to calculate a total based on the selections that the user makes. There are 13 selections total. There are two sections that I am stuck on, "Blue" and "Orange": If the User selects "Blue", $250.00 is added to the price If the User selects "Orange", $150.00 is added to the price The thing I am trying to figu...

php str_replace

I have this code $cl_posturl = "https://post.craigslist.org/".str_replace('"','',$result[FORM][0][ACTION]); echo $cl_posturl."<br>\n"; It if returning post.craigslist.org//sdo/S/ctd/csd/x/9FMALgak4Td10Bol/XRk68 it use to return post.craigslist.org//sdo/S/ctd/csd/x/ how can I modify the code to return it without those 2 last path...

Is there a way to create a Zend_Controller_Router that matches /text but not /text/ ?

I'm trying to match URLs without a trailing slash to one router and want those with the trailing slash behave the normal way. I've tried: $route = new Zend_Controller_Router_Route( ':redirectid', array( 'redirectid' => false, 'controller' => 'redirect', 'action' => 'redirect' ), array('redire...

How can I set up cron job in my site using PHP?

I want to mail after 6 hours automatically to my user who hasn't fully completed form on my website. Help Me ...

Kohana, .htaccess, and $_GET

After uploading my Kohana project to my Godaddy server, I noticed my standard .htaccess file wasn't working sufficiently to provide the clean URLs. After some guidance, I ended up with the following rule: RewriteRule .* index.php?kohana_uri=$0 [PT,L] This got my nice-URLs working again, but today I find out that it may be breaking my ...

Understanding the Wordpress vulnerability

A vulnerability has recently been disclosed that affects WordPress 2.8.3 and allows the admin user to be locked out of their account by changing the password. This post on Full Disclosure details the flaw, and includes relevant code snippets. The post mentions that 'You can abuse the password reset function, and bypass the first step an...

PHPMailer v. mail() for a simple Contact Form

I am new to PHP, but have a decent grasp of things (have not learned classes yet). The question: Which to choose? PHPMailer or mail() for my new contact form. The form is simple: Your name: Your email: Subject: Body: I have around 2,000 visitors per day and receive about 10 submissions per day, so I don't need anything too fancy. =...

cron jobs or PHP scheduler

Hi, I am using MYSQL as my database and PHP as my programming language.I wanted to run a cron job which would run until the current system date matches the "deadline(date)" column in my database table called "PROJECT".Once the dates are same an update query has to run which would change the status(field of project table) from "open" to ...