php

Catching a runtime exception in PHP

I am trying to catch a runtime exception that will be thrown by a function that is basically just a wrapper function for oci_execute(). For example: try { $SQL = "INSERT"; ExecuteQuery($SQL); } catch (Exception $e) { echo "<p>There was an error.</p>"; echo $e->getMessage(); } However, the exception doesn't appear to...

Access policy in PHP and MySQL.

I am slightly confused on how to setup my table. I have three roles which can be selected through checkbox. While registration.... if user selects one and two... then those pages should be visible, if he selected one and three then those pages and if selects anyone of them then those alone... Let us name the page 1 as client management...

Post SELECT element value

Hi! I use jquery to post data to mysql. **In settings.php i have this short JS code:** $("form#submit").submit(function() { var fname = $('#fname').attr('value'); var lname = $('#lname').attr('value'); $.ajax({ type: "POST", url: "settings.php", data: "fname="+ fname +"& lname="+ lname, success: function(){...

php return only duplicated entries from an array

i want to retrieve all duplicated entries from a array, how can it be possible in php. array(1=>'1233',2=>'12334',3 =>'Hello' ,4=>'hello', 5=>'U'); i want to return an array having hello out put array array(1 =>'Hello' ,2=>'hello'); ...

How do I properly split a PATH variable in PHP?

I want to split $path = getenv('PATH'); into its components. How do I determine the separator char in an os-dependent fashion? ...

How to Delete a File from a folder using PHP

Hello all, I am currently developing a IMAGE GALLERY site. Every thing is working well and GOOD except a small Problem. For example, if i am deleting a image in the site its deleting successfully from the database and no longer displaying in the gallery. But i need to remove the specific image from the folder. Is there any chance to do...

URL Problem in Ajax in PHP

When I open my site without "www", like http://mysite.com/, then there is a problem with my website hit counter on the home page, which is done through AJAX. The problem is that counter Image is not getting displayed. It is showing blank. There are similar problem on other pages where I have used AJAX to retrieve data. ...

How can I change PHP ini settings from within a shell script?

How can I set ini settings within a PHP script? php.ini isn't being read and ini_set doesn't work. Test File: #!usr/local/bin/php -q <?php // display_errors is set to false in /etc/php.ini // This shouldn't display any errors $test = $foo; // We can also try ini_set('display_errors', false); // This definitely shouldn't display an...

PHP - some pictures doesn't load (css problem?)

Hello, i am dynamically loading a website via file_get_contents with the following script. <?php header('Content-Type: text/html; charset=iso-8859-1'); $url = (substr($_GET['url'], 0, 7) == 'http://') ? $_GET['url'] : "http://{$_GET['url']}"; $base_url = explode('/', $url); $base_url = (substr($url, 0, 7) == 'http://') ? $base_url[2] ...

How can i get Contact list from mobile ?

Hi All, I am developing web application which is need to get the contact information from mobile(iPhone,Noakia, etc...).My application is in PHP.Please advice me over this issues Thanks in advance. ...

Wordpress limits - system design consideration.

I am designing a system for a customer. We are thinking about using Wordpress as a main platform (instead of writing our custom software), and customize it using addons or hiring developers to write some custom modules. We need to have an ability to have some static pages, few php pages, and lot of user generated content. What limits do...

MySQL performance – Multiple queries or one inefficient query?

Hi. I have three tables, each contain some common information, and some information that is unique to the table. For example: uid, date are universal among the tables, but one table can contain a column type while the other contains currency. I need to query the database and get the last 20 entries (date DESC) that have been entered in ...

Optimizing Kohana-based Websites for Speed and Scalability

A site I built with Kohana was slammed with an enormous amount of traffic yesterday, causing me to take a step back and evaluate some of the design. I'm curious what are some standard techniques for optimizing Kohana-based applications? I'm interested in benchmarking as well. Do I need to setup Benchmark::start() and Benchmark::stop() f...

Permissions set to 777 and file still not writeable

I have set file permissions to 777 yet I cannot write to the file with PHP. I can clearly see in my FTP client that the file has 0777 permissions and when I do: echo (true === is_writable('file.txt')) ? 'yes' : 'no'; I get 'no'; I also tried: echo (true === chmod('file.txt', 0777)) ? 'yes' : 'no'; With the same result. The direc...

PHP search for <link> tag and prepend

Hi! I'm using this code to prepend the url variabel inside the src tag for images. Now i would want an regex code that makes it possible to search for tags and add the url variabel inside the link tags href attribute. This code i have for the images, it might give u hints. function imgprepend_proxy($matches2) { $url = (substr($_GET[...

Zend_Search_Lucene - Can't create directory '/data/users_index'.

I have a problem creating an index with Zend_Search_Lucene. Now, everything works fine on my local machine so I guess there is just an issue with file permissions on the webserver. Here is how I'm trying to create index in controller: $index = Zend_Search_Lucene::create('/data/users_index'); Of course the data directory has permissi...

How to use memcached with Joomla

How can I use memcache in Joomla? I'm a newbie in this field so please be descriptive with your answer. ...

domdocument formatting

I am trying to read in the body of a certain webpage to display on a seperate webpage, but I am having a bit of trouble with it. Right now, I use the following code <?php @$doc = new DOMDocument(); @$doc->loadHTMLFile('http://foo.com'); @$tags = $doc->getElementsByTagName('body'); foreach ($tags as $tag) { $index_text .= $tag->nodeV...

session_start() followed by header() causing error

I have the following code in a PHP file called via Ajax (note - the code is a stripepd down version of the actual code, but still produces an error: <?php session_start(); $response = array( 'status'=>'abc', 'a'=>'abc', 'b'=>'abc', 'c'=>'abc' ); header('X-JSON: '.json_encode($response)); ...

Selections and localization with Smarty

I'm trying to implements selection lists using Smarty and I'm aware of the {html_options}. The application must support localization (which I implemented as described in this post). Is it possible to combine the two? I'm currently handling it by parsing through the items with {section name=i loop=$list} and "manually" generating the HT...