php

How do I find multiple matches with one regular expression?

I've got the following string: response: id="1" message="whatever" attribute="none" world="hello" The order of the attributes is random. There might be any number of other attributes. Is there a way to get the id, message and world attribute in one regular expression instead of applying the following three one after another? / messa...

Kohana3 - ErrorException [ Notice ]: Undefined index: id - Error calling Auth::instance()

Hello everybody, I've now a Problem with the newest Version of KohanaPHP (kohanaphp.com). After I've registered me and logged in into my test page, some minutes later, there is now the error: ErrorException [ Notice ]: Undefined index: id MODPATH/orm/classes/kohana/orm.php [ 1316 ] 1311 * 1312 * @return mixed primary key 1313 ...

Javascript find and scroll to text

I need a bit of Javascript that will find some text in the html page and then scroll to that point. So something like "Are you a Lib Dem or Tory supporter and how do you feel about the deal?" would scroll down to the bottom of the page for this bbc news page: http://news.bbc.co.uk/1/hi/uk_politics/election_2010/8676607.stm Im hoping th...

Jquery error "u is undefined"

Why am I getting an error in Firebug "u is undefined"? My page consists of a display of photos and photo gallery as a special separate section in the PHP code divided using the "break". Photos and photo galleries are displayed using the "Fancybox.js". The first time when I try to open a photo, everything works fine but when I do it a...

Selenium: How to select an option from a select menu?

I am writing a Selenium test in PHP using the PHPUnit Selenium extension. I know how to type something into a text field: $this->type('fieldName', 'value'); But how do I select an option from a drop-down menu? ...

set include_path for embed files like .js and .css?

OK so I now know there is a way to put all my php files in a single place and have them be able to be included without a filepath by setting an include_path like so: php_value include_path .:/pathToPHPFiles OK so now as long as my PHP files are in this directory I can include them from any subdirectory as if they were in the same dire...

PHP PEAR updating record with unique or primary fields

I have a PHP script that uses PEAR to access and update a MySQL table (below). The table has 2 primary key pair: code_class & code_value. I'm trying to update a table record with a code_value of "APP" to "APPL". A relatively simple task, right? But with PEAR, it seems like the primary key is throwing a wrench into task and rather tha...

Parse error: syntax error, unexpected T_STRING with index.php?

It works perfectly in local host but when I upload it intothe server it has the following error: Parse error: syntax error, unexpected T_STRING in D:\Hosting\4923367\html\beta\index.php on line 4 index.php: <?php include_once 'localization.php'; ?> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tr...

PHP require/include only works once in script then fails

Hi everybody, this isn't a problem as such but it's bugging me and I would appreciate any help. It might be totally obvious but I can't see it. $root_path = $_SERVER['DOCUMENT_ROOT'] require($root_path .'template/header.php') require($root_path .'template/footer.php') The script will include one or the other but not both. It will ru...

Can I check if e-mail address is valid?

How can I implement following logic? User registers with an e-mail address If provided e-mail address is a valid email address Then user account get's activated or if it is a fake email then user account is not activated I doubt that I can catch the - "Delivery failed reply message", right? anyhow how would you suggest to implemen...

PHP : Understanding why exec($my_command) hang

Hi, I have an exec() call wich never end, and my Apache/PHP process is blocked until timeout. It's an PostgreSQL database load like that "C:\Program Files\PostgreSQL\8.3\bin"\psql --host 127.0.0.1 --dbname unitTests --file C:\ZendStd\www\voo4\trunk\resources\sql\base_test_projectx.pg.sql --username postgres 2>&1 It run fine in comma...

How to check if Headers already been sent in PHP

Hi! I think most of us know about the infamous "Headers already sent" error in PHP. Can I check someway if headers already have been sent? It would be really handy to do such, before going all out with trying to set some SESSION data or similar. Thanks! ...

Accessing XML/PHP with period in tag

Hi guys, Quick newbie question here, how do I access totalResults? XML <?xml version="1.0" encoding="UTF-8"?> <OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"&gt; <opensearch:totalResults>1</opensearch:totalResults> <posts> <post> <score>10</score> </post> </posts> </OpenSearchDescript...

.htaccess or PHP protection code against multiple speedy requests

Hi, I am looking for ideas for how I can stop external scripts connecting with my site. I'm looking for the same kind of idea behind Google. As in if a certain amount of requests are made per a certain amount of time then block the IP address or something. I thought there maybe a htaccess solution if not, I will write a PHP one. Any id...

How to get base url with php?

I am using XAMPP on windows vista. In my development, I have http://127.0.0.1/test_website/ Now I would like get this http://127.0.0.1/test_website/ with php. I tried something like these, but none of them worked. echo dirname(__FILE__) or echo basename(__FILE__); etc. I will appreciate any help. Thanks in advance. ...

[WordPress] Paging on Index Page Not Working With posts_per_page

I'm working on a theme that has both a project page and a blog. I want to keep the blog posts at the default of 10, so I used the posts_per_page option to limit the number of projects on the first page, like this: <?php $catID = get_cat_id('Projects'); $number = get_option('grd_portfolio_number'); if(have_posts()) : $paged = (get_query...

Stacking standard output of `su`

I've got some code that I wrote that uses a combination of bash and PHP command line scripting. The script is ran as root and then uses su to become various uses. I start a session like this: $result = `su SomeUser ./dothis.php` Here ./dothis.php is a script that may generate some output being stored in $result, but the problem is tha...

Selenium: How to assert that a text field is disabled?

I am using the PHPUnit Selenium Extension for Selenium RC. I am able to assert the field is present: $this->assertElementPresent('Date'); But how do I assert that the field is disabled (or not editable)? ...

Context aware breadcrumbs with php sessions - Will search engines index each variation?

Some pages on my website appear differently depending on where the user has been, using php sessions. for example with breadcrumbs: standard crumb setup: All Books -> fiction -> Lord Of the Flies if the visitor has just been on the 'William Golding Page', a session will have been created to say, this visitor is broswing by auth...

php, mySQL - how to create a table?

Hi guys, I have written a code that should check weather there is a table called imei.$addimei and, if not, create it... $userdatabase = mysqli_connect('localhost', 'root', 'marina', 'imei'); ... $result = mysqli_query($userdatabase, "SELECT * FROM imei".$addimei."" ); if ( !$result ) { echo('creating table...'); /// if no such table, m...