php

Catch PHP Fatal Error

I have a web service site that is restful enabled, so other websites/ajax script can make a call to the site to get/set data. However, whenever the web service site somehow returns a PHP fatal error, the HTTP status that is returned is 200 instead of 500. Is there a way to fix it so that whenever a fatal error occurs, returns 500 instead...

php execute page

I want to call a page (click.php) on a click of a button, click.php executes a php-mysql command that inserts a value into a table. Is there a way to click the button and have the page execute without page load. An example: when you do +1 rep on this website to someones post, Im assuming its database driven and when you give them rep, it...

Building gearman type application using RabbitMQ

Hi, I'm looking for a general overview of best practice to implement a "job allocation" system like Gearman using RabbitMQ messaging system. So basically I'd have something reading the queue and forking? instances to run a job? Any insight is appreciated. ...

How do I parse a string for a particular delimited section within PHP?

Hi folks, I have a string, for example "[{XYZ123}] This is a test" and need to parse out the content in between the [{ and }] and dump into another string. I assume a regular expression is in order to accomplish this but as it's not for the faint of heart, I did not attempt and need your assistance. What is the best way to pull the fr...

jQuery in CodeIgniter, inside the view or in external js file?

I'm developing web application using CodeIgniter. All this time, I put the custom js code to do fancy stuffs inside the view file. By doing this, I can use site_url() and base_url() function provided by CodeIgniter. Today I want to separate all custom js code from view file into an external js file. Then it hit me, I cannot use site_url...

Can't login to my project using google or Yahoo OpenID

Hi guys I've set up an openID login system - just like the one we have here on stackoverflow and on the backend I'm using JanRains libraries. It was working fine until all of a sudden - people can't login using a google or yahoo openid. ITs constantly failingt - instead however any other regular openid seems to work fine. WHats going on ...

Help with UNIX time to human time

I need to format a UNIX timestamp in GMT format to a local date/time. I'm using gmstrftime to do this and I can get the correct result if I use an offset. I just so happen to know what my offset is for the pacific timezone but I don't want to have to get the correct time like this. I've used date_default_timezone_set so gmstrftime is rep...

URL parse function

Hello, Given this variable: $variable = foo.com/bar/foo What function would trim $variable to foo.com ? Edit: I would like the function to be able to trim anything on a URL that could possibly come after the domain name. Thanks in advance, John ...

A question about query result judgement in PHP and MySQL

Code as follows: $db = DatabaseService::getInstance(); //get a database handle,base on pdo $sql = "select * from authusers where ssouid = '".$ssouid."' order by regtime"; $res = $db->query($sql); if($res && $res->fetch()) // here is the Problem line { //do something } else { //raise some exception } In the problem line,I wa...

How to add curl support to PHP 5 in CentOS

How to add curl support to PHP 5 in CentOS ? After installing curl and curl-devel, what are the things that I need to do to setup curl in PHP 5 ...

mysql query for getting all items and removing one item based on a criteria

so here's what I accomplished right now: given email1 and email2, get all emails that are not equal to email1 create a list of them check if email2 exists in the list if it does return false, if it does not return true Is there a way to accomplish this via a query instead of creating a list and searching if email2 exists in it? (beca...

Adding More Than One App To Fan Page

Hello, I have created this fan page http://www.facebook.com/pages/ohlala/327385737341 and added an application on tab "Special Offers". I just wanted to know if it is possible to add more than one app to the fan page? Can't see any option like i did for the first app. Thanks ...

Clone object to $this

Dear all, I would like to ask about PHP clone / copy object to $this variable. Currently I am new in MVC, I would like to do something like CodeIgniter. I would like to direct access to the variable. in my __construct(), i always pass the global variable inside to the new controller (class), eg. function __construct($mvc) { $t...

How to Retrieve image from database?

In my Database, the images(jpeg,bmp format) are stored in bytea datatype, showing up in binary code in the database. Now I want to retrieve the images from the database. But i could not get the image in the web page. When i retrieve using this code given below, it shows the binary code value.(ie combination of numbers,characters,symbols)...

How to set args when debugging a php cli file in zend studio?

In a prompt we can run: php filename.php args But how to set the args in zend studio? I've searched for this some time,and don't seems to find the example. I can only debug without args by simply pressing F5 ...

Download Multiple files in one HTTP request

hi, how is it possible to download multiple files in one HTTP request? what i mean it's like when you have multiple attachments and you select what you want to download then press download so they will be automaticcaly downloaded and you don't have to click on each one manually. i'm using PHP as a serverside srcipting. thank you ...

How to encode URL in JavaScript and PHP?

I want to send a URL in a POST request in a variable called surl. How should I encode it in JavaScript and decode it in PHP? For example, the value of surl could be http://www.google.co.in/search?q=javascript+urlencode+w3schools. EDIT Sorry, I forgot to mention, it's not form submission but a ajax request. ...

Storing checkbox values in a MySQL database then retrieving whether they're set or not... what is the best method?

Hi everyone I have a form where users can submit sites and say if they work in different browsers. Currently, it looks like this: <input type=checkbox name="browsers[]" value="IE6"/>Internet Explorer 6<br/> <input type=checkbox name="browsers[]" value="IE7"/>Internet Explorer 7<br/> <input type=checkbox name="browsers[]" value="I...

Using timestamp type with pg_prepare

Running the following code: $preCallMatch = pg_prepare($dbcp, 'callMatch', "SELECT duration FROM voip_calls WHERE system_id = $1 AND call_start => $2 ...

echo line returns in html source code

How do you implement line returns when the html code is between simple quotes. The only way I found is to concatenate the line return between double quotes: echo '<div>'."\n" .'<h3>stuff</h3>'."\n" .'</div>'."\n"; Which lucks ugly to me. Edit: The code between the simple quotes is quite long and with many attributes otherwis...