php

What is the use of creating functions within functions?

I know that it is possible to create a function within another function. Why might one need to do that in real life? (PHP) function someFunction($var) { function anotherFunction() { return M_PI; } return anotherFunction(); } ...

PHP SOAP client help!

Hi guys, I have to create a PHP SOAP client that sends leads, but I have never worked with SOAP before, and my XML isn't that great, here is the code I have managed to write so far. . . <?php try { $client = new SoapClient(null, array( 'location' => "https://wwa.website.co.za/CallmasterTes/LeadService.asmx", ...

Why in this php code the indexes ["name"],["price"] and ["id"] won't display any data?

$result= mysql_query("SELECT cart.id cart_id, dkb.id dkb_id, cdkb.id cdkb_id, dbl.id dbl_id, cart.*, dkb.*, cdkb.*, dbl.* FROM cart LEFT OUTER JOIN dkb ON ( cart.id = dkb.id AND dkb.id = '".$ids."' ) LEFT OUTER JOIN dbl ON ( dbl.id = dkb.id ) LEFT OUTER JO...

Ignore duplicates when using INSERT in a Database with Symfony and Doctrine

I have a table CREATE TABLE `sob_tags_articles` ( `tag_id` int(11) NOT NULL, `article_id` int(11) NOT NULL, `id` int(11) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=112 And triing to save an object with Doctrine: $sbTagsArticles = new SobTagsArticles(); $sbTagsArticles->article_id = $pubId; $sb...

PHP forking and multiple child signals

I'm trying to write a script which creates a number of forked child processes using the pcntl_* functions. Basically, there is a single script which runs in a loop for about a minute, periodically polling a database to see if there is a task to be run. If there is one, it should fork and run the task in a separate process so that the pa...

Getting the key of the only element in a PHP array

The key of the associative array is dynamically generated. How do I get the "Key" of such an array? $arr = array ('dynamic_key' => 'Value'); I am aware that It is possible to access it through a foreach loop like this: foreach ($arr as $key => $val) echo "Key value is $key"; However, I know that this array will have only one key an...

How to develop a project in Japanese language?

Hi! I am a php programmer and i have to develop a site in Japanese language using php. I know i have to use unicode for this. But did not find how to install the unicode and how to use it. It would be great help if anyone provide me solution or the link. Thanks in advance. ...

PHP looking for a neat way to prevent unauthorised users from viewing pages

I'm looking for a way to prevent unauthorised users from viewing pages without, lets say, wrapping everything in an if authed { show page } else { show error} My website is currently setup like: index.php require_once __WEBROOT__ . '/templates/default/header.tmpl'; require_once content('p'); require_once __WEBROOT__ . '/templates/defa...

get id of last inserted record without using mysql_insert_id()

$sql = 'INSERT INTO customer (first_name, last_name, email, password, date_created, dob, gender, customer_type) VALUES(:first_name, :last_name, :email, :password, :date_created, :dob, :gender, :customer_type)' . ' SELECT LAST_INSERT_ID()' ; Can anyone tell me if the syntax is right? I am having problems usin...

Adding more source folders to a NetBeans PHP project

Is it possible, with or without plugin, to add more source folders to a PHP project, just like in a Java project? I have downloaded and tested the Java version of NetBeans, and there is clearly possible to add more source folders. But not in the PHP version? ...

search big database

I have a database which holds URL's in a table (along with other many details about the URL). I have another table which stores strings that I'm going to use to perform searches on each and every link. My database will be big, I'm expecting at least 5 million entries in the links table. The application which communicates with the user ...

How does symfony choose the very content type?

txt: text/plain js: [application/javascript, application/x-javascript, text/javascript] css: text/css json: [application/json, application/x-json] xml: [text/xml, application/xml, application/x-xml] rdf: application/rdf+xml atom: application/atom+xml It is used by the framework to automatically manage the Conte...

Smarty echo of array variable with "-" in its name

Hi, I have variable that in PHP controller looks like $data['content']['mods']['HTML-FORM-END']['html'] It is passed nicely in smarty, but when I try to show it any of these ways, it shows either 0 (assumes minus as operator and does some math), or says "unrecognized tag" {$data.content.mods.HTML-FORM-BEGIN.html} {$data.content.mods[...

restart asterisk flash operator panel server from the web

Need to restart asterisk flash operator panel (fop) from the web after configure file (op_buttons.cfg) is altered. Web server runs under daemon user. Via root user restart works. ...

Optimize Nginx + PHP-FPM for faster response times (for Openx adserving)

I'm currently running Nginx + PHP-FPM for serving ads on OpenX. Currently my response times are horrible, even during times of low load. However, my CPU and Memory resources are fine, so I can't seem to figure out what the bottleneck is. My current config for nginx and php-fpm is: worker_processes 20; worker_rlimit_nofile 50000; error_...

htaccess rewrite rule doesn't work

Hi, in my .htaccess file i do have these lines: Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([a-zA-Z0-9_-]+)/([0-9])/([a-zA-Z0-9_-]+)\.(html)$ /first_gate/index.php?show=true&_=$1&__=$2 [QSA] So calling: http://www.domain.com/a-b-c-d/123/an-thing-here.html in the background it's intend...

create a images for dynamic text using php

Hi, I want to create a images for my dynamic text. My problem is that i am reading folder name from some specific directory. So folder name will be what ever but client wants that folder name should come as the images only. So i have thought that i will place one image with the same name as folder on any unique name. but client don't wa...

PHP Session help

Hello, I have a session that works perfectly expect for one, if I close the browser the session gets destroyed however if I close the current tab and then go back to the site, the session still exists, how can I make sure that the session is destroyed both on a tab close and a window close? ...

How can I access a codeigniter config variable from a model/controller?

I would like to access the $db['default']['dbprefix'] variable from /application/config/database.php from within a model so I can write my own queries using the value from the file. How can this be done? ...

Annoying problem with routes in Kohana 3

When I access my site on MAMP like so, it works great localhost/site/about-us/ When I upload it to my remote server, and access it like this http://www.server.com/site/about-us/ all requests go back to the 'default' set up in bootstrap.php. Here is my route setting. Route::set('default', '(<page>)') ->defaults(array( ...