php

How do I catch strings that don't start with "ajax/" using regex for CodeIgniter?

I'm working on some routes for my CodeIgniter application, and I need to declare a 'catch-all'/except one regular expression. Any route that doesn't start with 'ajax/' should be redirected to the 'main'-router. Like so: $route['regexmagichere'] = "main"; So this is definetly way beyond my regex skills and I need some help. The regex s...

PHP APC and Memcache Benchmarking

Is there any simple test I can try to benchmark APC and Memcache, just to get a sense of the performance benefits of using them? I tried some simple stuff using microtime() and looping requests to my database and storing the results, first in cache and then without, but I didn't notice any significant performance boost. Thanks. ...

php get the variable name from other variable

look at this simple script please $c1 = $_GET[c1]; $c2 = $_GET[c2]; $c3 = $_GET[c3]; $c4 = $_GET[c4]; $c5 = $_GET[c5]; for($i = 1;$i <=5;$i++) { echo $c{$i};//or something else here :/ } how can i print tha values of variables? Thanks ...

Setting value of a HTML form textarea?

Hey guys, I'm using the following to set the value of a text area.. <?php $message = $_REQUEST['message']; ?> <br/><b>Description</b><br/> <TEXTAREA NAME="message" COLS=40 ROWS=6 value="<?=$message;?>"></TEXTAREA><br/><br/> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> but it doesn’t appear to be working. The value of ...

how do you add a named range to worksheet using php pear spreadsheet excel writer

Is it posible using Excel_spreadsheet_writer to create a name such as $workbook = new Spreadsheet_Excel_Writer(); $worksheet = &$workbook->addWorksheet('CheckNames'); $worksheet->writeName(0, 0, 'AnswerToEverythig', '42'); $worksheet->write(0, 1, 'Double ='); $worksheet->writeFormula(0, 2, '=AnswerToEverythig * 2'); $workbook->send...

PHP xls, xlsx, ppt, pptx headers

Here is my code where I am trying to send a correct header depedning on a type of a document. I figured out the headers for pdf, doc and docx but I still need to know correct header for Excel and Powerpoint files. Any help appreciated. $document = urldecode($_GET['document']); $extension = end(explode('.', $document)); $m...

Is this a php variable variable bug?

Is there a logical explanation to this? <?php $$a = 'hello world'; echo $$a; //displays hello world echo $$aa; //displays hello world echo $$aaa; //displays hello world ?> ...

Question about a simple PHP Autoloader

I was just learning aboutt PHP namespaces and starting to create a simple autoload function. What O did was: function __autoload($name) { echo $name . "<br />"; require_once $name . ".php"; } So, this works if I do not use any aliasing or importing statements eg. use MainNamespace\Subnamespace because if I did that, assuming i hav...

How else might a PHP CLI script determine its memory limit?

I need to run a PHP CLI script and give it a LOT of memory (it's an automatic documentation generator that needs to cover a large code base). I have a powerful machine and have allocated 5GB to php, both in php.ini and in an inline ini_set('memory_limit','5120M') declaration in the script file. If I add these lines to top of the script...

How do i know if the request came from flash swf?

I have an application developed in flash, and I need to access some php files. so the php file return some data if the access is came from swf. How can i identify if the request came from flash or not? without passing get/post variables to php. ...

Login Javascript within PHP

Hi, I have been creating a web scraper for an internal application with PHP but one of the pages has a JavaScript login is there any way of autonomously logging in to scrape the data as usual? (I am using curl to log in to the other two sites) ...

mysql field length

How do I find the longest value in my mysql table? I have a php script and I want to search my table to find the record with the longest string? Any ideas? ...

concatenating two variable into one

I'm new here and kind pretty new to PHP and I'm no sure as to why this is not working. If I echo $ordernum1, I get the value I look for, but echoing echo ${"ordernum".$x}; gives me nothing. I have also echoed $attempts and I get the value I'm looking for. Any help would be great thank you $update=$_POST['update']; //echo $update; $att...

PDO SQLite: read-only database

I have a SQLite database that I am using for a website. The problem is that when I try to INSERT INTO it, I get a PDOException SQLSTATE[HY000]: General error: 8 attempt to write a readonly database I SSH'd into the server and checked permissions, and the database has the permissions -rw-rw-r-- I'm not that familiar with *nix permis...

Php/Java Integration

Hi Everyone! Have u experience of integration of php and Java. I've written a class in Java "Hello". Now I want to call its method from php when I create an instance of this class from php with $obj = new Java(Hello); Then it gives me fatal error. I've tried many times to setup php ini variables etc but I couldn't find any thing. Pl...

php headers already sent error

I have a single php file, with this code in it: <?php header("Location: somepage.php"); ?> Absolutely no spaces before or after the php opening or closing tags and I am getting the Warning: Cannot modify header information - headers already sent by (output started at C:\ ... \test.php:1 Usually when I get this error, the 1 is the ...

Can't get "Syntastic" vim plugin to work.

I've installed Syntastic plugin in vim. I can't get it to work. I've tried :SyntasticEnable but no luck. SyntasticEnable python in my vimrc doesn't work either (in fact, it doesn't even parse the command, an error is shown when I try to add it to my .vimrc : Not an editor command: SyntasticEnable python). How can I know what's going on?...

How to reach PHP-Document on Webserver with Adobe AIR HTML/JS/jQuery

Following thing: Within my Adobe AIR Application (I use the HTML/JS/jQuery variant, not the flash/flex variant) I want to contact my Web Server where a PHP-File is stored that handles database interaction. So I want my AIR-App to request data from the php file (the db) and show it. But when I make a request with .ajax() the AIR Runtime s...

What are session_id, session_regenerate_id and session_name used for?

ok im a newbie on sessions lets imagine that we have a little login site, heres a logic login if password right = use $_SESSION[isaloginuser] = 1 check session to see menus with if $_SESSION[isaloginuser] = 1 show the menus the user want to logoff unset session destroy session system what it use session_register session_destroy ses...

Should I run multiple SELECTs inside a PDO transaction for performance gains?

Are PDO transcations intended just for UPDATE, INSERT and DELETE or can you achieve performance gains if you use a transaction for mulitple SELECT queries? ...