php

Which alternatives do I have for developing a website navigation without .htaccess?

Just in theory: Almost all modern websites work this way: somedomain.com/layer1/layer2/action For example: http://stackoverflow.com/questions/ask Typically this is done with .htaccess and ModRewrite Engine. A while ago I stumbled over an article that described something which came right out of php. I don't remember the name anymore...

preg_replace() called with arrays needs ksort() beforehand? Huh?

I was working a bit with preg_replace over the weekend and I was reading the Php preg_replace documentation when I saw something odd. Example #2 from the docs shows that when given the following php code <?php $string = 'The quick brown fox jumped over the lazy dog.'; $patterns[0] = '/quick/'; $patterns[1] = '/brown/'; $patterns[2] = ...

how to avoid background-color flash while loading up a web page?

I have a website (using PHP). The main background is of green color and content area is of white. While switching to one page to another (as it takes a few milliseconds) the background color gives a flash before the white takes it over. I think its because of the way the dom element being drawn/created. I tried using ob_start(); and ob_f...

php regular expression

Hello guys i am trying to get the text inside specific <td's>. Each one has a id="uniqueName" - Such as: <td id="engineTypeField" class="normal2" colspan="2"> 3.0L L6 SFI DOHC</td> but i am having bad luck - learning regexp as doing so This is what i have: preg_match ("<td id='\/engineTypeField\/(.*)>(.*)</td>i", $result, $matches); /...

Why form posting yields $_FILES['thefile']['name'][0] instead of $_FILES['thefile'][0]['name'] ?

When you name several file input fields with the same name and an array index like so: <input type='file' name='thefile[0]'> <input type='file' name='thefile[1]'> Then in the form submission you get this: $_FILES['thefile']['name'][0] $_FILES['thefile']['name'][1] And so on with the other fields. I find this annoying because it preve...

Why does mysql_affected_rows return 0 even if one record should be updated

mysql_query("update users set balance=balance+'$pwbalance'-'$totalprice' where memberid='$memberid' and (balance+'$pwbalance'-'$totalprice')>=0")or die(mysql_error()); $count=mysql_affected_rows(); When I echo $pwbalance, it is 40.00; when I echo $totalprice, it is 40; So there should be one record to be updated. However, when I echo $...

Guidance, tips/tricks for larger scale php development.

Hi A project that I maintain and develop in asp.net so far has over 500 c# files (including code behind), 150 aspx, dozens of web controls, masterpages, split over various projects; web, business, cms. There are other projects that are accessed as web services (FYI developed mostly in Java by other teams). This current project is hoste...

Query a PHP semaphore without blocking?

Hi. Is it possible to query a semaphore created with sem_get without actually blocking like the sem_acquire function does? Cheers, Dan. ...

Can you rely on the order that regular expression syntax is interpreted?

(The background for this question is that I thought it would be fun to write something that parses wiki creole markup. Anyway the problem that I think I have a solution to is differentiating between // in a url and as opening/closing syntax for italic text) My question is slightly compound so I've tried to break it up under the headings...

Use PHP to parse a confirmation email?

I'm integrating my website with a third party system. Here's the workflow between my website and the third party system: 1) From my website, I use PHP to automate upload of a CSV file to the third party system. 2) After the third party system receives my file, it will conduct a few operations. 3) The third party system will email ...

Getting the update row_count in mysql using php.

This is a very simple example: I have a table with two columns, id and password. I want to know when an update was done successfully, with success being defined as applied to an existing row. PHP seems to only offer mysql_affeted_rows(), which doesn't differentiate between 0 rows affected, and 0 rows updated. http://php.net/manual/en/f...

Is it possible to disable the php gettext extension in .htaccess or php runtime ?

Hi, I am using a shared hosting, i need to disable gettext extension for my application due i need to redeclare _(). Is it possible to disable an extension on php runtime or vie .htaccess ? ...

Run php from command line in 32-bit mode

Is it possible to tell php to run a script from the command line in 32-bit mode? I have a php script that uses an ODBC driver that is only works when PHP is run in 32-bit. Here is how I'm calling the script: php -d safe_mode=0 -f checkImport.php Any ideas? ...

Converting a .php file to a .html file?

Hello everybody, I have a .php file which has several queries in it. I want the output file as a .html file... Is there any way to do this. I am currently doing this by saving, using my browser, that executed PHP file, as an .html file. But when I launch my product that should not be the case of the client. Please suggest a way, thanks...

Why are my links not showing up via php email function?

I am trying to send notification emails(which is working fine) but have added the html headers to try to send links etc...for some reason nothing is showing up at all, just blank space where the desired links are supposed to be. Here is my code: if(isset($_POST['commentBlogSubmit']) && $auth) { $query = "SELECT `Email` FROM `Users`...

PHP mail() error; I can't see for looking!

Hi, I'm having an issue with a simple PHP mailer. I've had this script working, but it now doesn't work and I can't see for the life of me why not. It's instead spitting out the raw HTML rather than the rendered template. If someone could have a browse and get back to me then that would be great. Thanks in advance. <?php if (isset($_P...

looping through a set of radio buttons and find if its empty in PHP

my question is that i have a group of radio buttons and all are grouped into one 'x0'.Now how do i iterate through this radiobutton group using foreach ,and find if its empty/or not and do further operations based on the value? <tr> <td><input type="radio" name="x0" value="0" <?=$x0?>> 0. </td> </tr> <tr> <td><input type="r...

Cakephp - Updating information on a logged User

Hello, I have a controller named sales_controller at this controller I got a function in wich I want to: update information about the sale -> DONE create a new record on other model -> DONE update a field on a user record -> PROBLEM My last attempted to do this was: App::import('model','User'); $user= $this->Auth->user(); $nr = $t...

pg_query show/describe tables

Is there a way to show all tables, describe them \d and dump the result on php? Any ideas will be appreciated ...

Including template files and dynamically changing variables within them

To make life a little easier for myself I would like to build a very simple template engine for my projects. Something I had in mind was to have .html files in a directory that get included to a page using PHP when I want them. So a typical index.php would look like this: <?php IncludeHeader("This is the title of the page"); IncludeBod...