php

htaccess turn on php flags if certain IP address

In my .htaccess file I need to turn on the following: php_flag display_errors On php_value error_reporting 2147483647 However I only want to do this if my IP is visiting the site. Any ideas? Something like... if (ip == "x.x.x.x") { php_flag display_errors On php_value error_reporting 2147483647 } Need to do this in .htaccess ...

mysql queries - performance loss by putting numbers in quotes?

If a variable will always be a number, is there a performace loss by putting it in inverted commas? for example "SELECT prod.product_name FROM prod WHERE prod.id = '$id'"; ...

Force result for empty() test on an object

Hello ! Simple class for example: class Foo { protected $_bar; public function setBar( $value ) { $this->_bar = $value; } } And here is the question: $obj = new Foo(); var_dump( empty( $obj ) ); // true $obj->setBar( 'foobar' ); var_dump( empty( $obj ) ); // false Is it possible to change class's b...

JavaScript apparently waits for each AJAX call before sending another in a loop

Hello. Straight to the point: I have this javascript: for(item=1;item<5;item++) { xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET",'zzz.php', true); xmlhttp.send(); } And in PHP file something like this: usleep(5);die('ok'); Now the problem is javascript seems to be waiting for each ajax call to be completed before send...

converting GPS latitude/longitude from different formats to one format (in PHP)

Hi. i'm trying to built in support for locations in my application and i'm expecting users to be inputting gps coordinates in a variety of ways. I need to convert all of the below to: latitude - direction (N/s), degres, minutes, seconds; longitude (E/W) - degrees, minuts, seconds. Note, each user input will be in a single line. I would ...

Generating forms from the database

Hello I'm trying to teach myself Drupal and I've found something I can't find any tutorials for. I am trying to generate a form, with a dynamic number of text fields, to populate and edit the contents of my custom table. In regular PHP I would achieve this with: $count = '0'; while ($row = mysql_fetch_array ($result) { echo "<input ...

php: how to return an HTTP 500 code on any error, no matter what

Hi guys. I'm writing an authentication script in PHP, to be called as an API, that needs to return 200 only in the case that it approves the request, and 403 (Forbidden) or 500 otherwise. The problem I'm running into is that php returns 200 in the case of error conditions, outputting the error as html instead. How can I make absolutel...

Pi help with Php (mass looping)

My primary question is: Is this alot of loops? while ($decimals < 50000 and $remainder != "0") { $number = floor($remainder/$currentdivider); //Always round down! 10/3 =3, 10/7 = 1 $remainder = $remainder%$currentdivider; // 10%3 =1, 10%1 $thisnumber = $thisnumber . $number; $remainder = $remainder . 0; //10 $decimals += 1; } Or could...

Add 30 seconds to the time with PHP

Hey all, just wondering how I can add 30 seconds on to this? $time = date("m/d/Y h:i:s a", time()); Thankyou, again. I wasn't sure how to do it because it is showing lots of different units of time, when I only want to add 30 seconds. ...

I want to add and remove items from a menu with PHP.

This menu will need to be updated daily. <html><head></head><body> <h1> Welcome to Burgerama </h1> <?php include("menuBuilder.php"); showBurgerMenu(); ?> </body></html> Menu items are stored in the database. Items have a display field; if it is on, the item should be displayed on the menu. The menu only displays 4 or 5 "specials"...

preg_replace ('/σ/', 'ς', $cat_name);

Hi, how can change only the last letter of any word of a string with regular expressions? I use mb_strtolower() for change strings from upper to lower in Greek language and I have problem with final 's'. ...

Drupal 6: display CCK Field value with php in views_customfield

SORTED http://drupal.org/node/467190#comment-2068324 Hi friends, I've spent all day to find but can't find :( How can I display CCK Field value with php in views_customfield? I tried the ones below, but no result $node->field_homepage_linking[0]["view"] $node->field_homepage_linking[0]["value"] value_get('field_homepage_linking...

How to push values into an array along with incrementing the array index while inserting?

I have a an array I want, whenenever i submit my form the post value get inserted into that array, every time with new incremented index.. How can I do that? And yes submited page is redirected to itself... ...

Why are scripts given .phtml extension while working with zend framework?

Why are scripts given .phtml extension while working with zend framework? ...

Unneded number combination after replacing a number in a string.

I get an unneeded number combination. ($_COOKIE): 2, 3, 4, 5, 6, 7, 8, 901234567890123456789, 30 Should be ($_COOKIE): 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12... (till) 30 $_Get['id']="1"; (sorry, forgot to post it.) Why that happens? The code: <? ob_start(); $id=$_GET['id']; if (!empty($id)){ $id=str_replace('a9_',''...

How to get expected url

I have developed a website, using Twitter API. Now a little but important problem I am facing is expected URL. There will be users on my site who are going to get details with their user name. My site url right now is : www.mysite.com/ It also works on : www.mysite.com/home.php and : www.mysite.com/FinalShow01.php Now what I want is us...

Cakephp problem with translation behavior

I use cakphp version 1.3. The documentation says, that if I want to use the translation behavior for my dynamic content no changes in my view are necessarily. The problem is, that the translated fields are there but empty. The translation only appears in the ['I18n'] array like this Array ( [0] => Array ( [Cat...

hi how to show a pop up box if there is some result for the mysql query?

Hi I have a message box in my project if one have to check some message they have to enter the message link to check message instead ,I am thinking of showing a message in a popup box if the query where i am fetching the messages is not empty ,,(i,e) if there is any unread message in users account must,trigger a popupbox with message...

Can't seem to get Prototype AJAX form validation to work in conjunction with Codeigniter

Is there some kind of trick involved? Here's how I would envision it working: 1) User tries submitting the form 2) Event.observe captures this and sends an AJAX request to a special validation URL (PHP using Codeigniter) 3) If no errors were returned, continue submitting the original form 4) If errors were found, cancel form submiss...

Question about a dialog form and submit errors

Hi, I have the link below that executes the action message/new which shows a form inside a jqueryui modal dialog. <div id="myDialog"> </div> echo jq_link_to_remote('Enviar mensaje', array( 'url' => 'mensaje/new?receptor='.$miembro->getId().'&tipo=0&estado=0', 'update' => 'myDialog', 'complete...