php

why cant I do this in js

I want to do this <?php $dropDown = "<select><option value=\"0\">1-50</option><option value=\"50\">51-100</option><option value=\"100\">151-200</option></select>"; ?> <html> <head> </head> <body bgcolor="333333"> <script language="javascript"> <!-- var params = new Object(); params.dropDown = <?php print $dropDown; ?>; </scri...

check for valid email address

Possible Duplicate: What is the best regular expression for validating email addresses? hello, can you help with my coding? my problem is this: when the user wants to register, and when he entered his email. how can i check if it is valid or not? i use this code. please help me. tell me if its correct because i'm only a ...

Problem with array_key_exists

Hey there, I'm implementing some affiliate tracking to my site. The affiliate network has asked that I hide the telephone number on the site. When an affiliate clicks on a link to my site, any of the site URLs will be appended wth something like /?source=affiliate&siteid=XXXX for example; mydomain.com/?source=affiliate&siteid=XXXX I'v...

How to get form input array into PHP array

I have a form like the one below which is posted to contacts.php, and the user can dynamically add more with jquery. <input type="text" name="name[]" /> <input type="text" name="email[]" /> <input type="text" name="name[]" /> <input type="text" name="email[]" /> <input type="text" name="name[]" /> <input type="text" name="email[]" /> ...

Pass values from array to object? - PHP

My problem, simplified is: class A { public $a; public $b; function f1 () { // Code } } $obj = new A(); $arr = array ("a" => 1, "b" => 2); How can I put the contents of $arr into $obj? (Obviously without $obj->a = $arr["a"], suppose there are thousands of values) Thank you. ...

php: force download to hd?

header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-type: application/force-download"); header("Content-Disposition: attachment; filename=\"". $file ."\";"); header("Content-Transfer-Encoding: binary"); header("Content...

php convert 1000 to 1,000.00

I was wondering if there is any php function to convert the number of 1000 to 1,000.00, 10000 to 10,000.00 and so on . I can write a regex but I just want to know if there is any php build in function like floor . ...

How can I make folder available to only VB.NET application?

I have build a VB.NET application which uses PHP command line to run some scripts in a folder in the same directory. I do not want the script in PHP directory to be editable. So, I want that folder to be inaccessible by users or only available to my applicaiton. Any Idea how can I achieve this? ...

How do I replace spaces into hyphens in an URL.

I have some data that is inputted into to a database with spaces. e.g. first and last names. I then need to call that data from the database and display it as a link so i have a friendly URL. I am not sure if I should do this with mod-rewrite or php. What is the best solution? A solution like below doesn't seem to work str_replace('- ...

how can i recall data from an SQL table TEXT field into and HTML textarea using PHP? (all part of a simple Article Management System)

I building my own simple article management system, and have run into a bit of trouble upon creating a page to edit the articles. I am able to recall the title and tagline of the articles in the form input using the 'value' attribute. However, I am yet to work out how to do the same thing with the form textarea as it has no 'value' att...

Allow only letters; no punctuation no numbers

Hey guys can you help me with this. I've got this '/[^A-Za-z]/' but cannot figure out the punctuations part. Gracious! ...

Sending stuff with PHP and POST.

Hello, how I SEND stuff with PHP and POST? (not how to grab, or how to send from html... but how to send from PHP... the particular PHP script is not even running in a webserver, neither is part of a web-page). I looked everywhere on google, but I keep finding examples of how to use a html form, and how to use $_POST to get the results....

CSV with multiple header rows; import into mysql using php

Hi, I've got a CSV file with two sets of data in it [its pulled of a temperature logger]. I'm wondering if there's a way to import the first two rows as one set of data and the rest as a second set of data. I'm familiar with PHP, but have never had to do anything like this. I've attached a subset of data below. Any help or direction woul...

Making ExpressionEngine .htaccess allow commenting on index.html

I've got a really quirky issue going on with ExpressionEngine. I've got a live test site here. Essentially, if you attempt to comment on the index's 'Question of the Day,' you get a proper redirect, but the comment never gets to the database. If I remove my .htaccess and set the site's index page in my control panel to index.php, then ...

BIG Resource eater

This script is eating up a lot of resource on my members computers. I have other interval scripts that don't eat up any resource. I've tried extending the time but that slows down the refresh. Any suggestions? <script type="text/javascript"> $('document').ready(function(){ updatestatus(); scrollalert(); }); function updatestatus(){ ...

Programming Asterisk PBX using PHP?

Ok I installed asterisk, now I would like to know how do I program asterisk PBX using PHP? Does Asterisk have an API that I can work with? Please provide basic examples how I could perform the following scenario send phone number to asterisk asterisk dials phone number ...

PHP: How can I tweak PHPUnit to use a different PHP interpreter?

My system has two PHP interpreters. One came bundled with the OS and the other I installed via the XAMPP package. All of my PHP extensions are applied to the XAMPP installation but PHPUnit seems to only run the version of PHP that came with my machine. Does anybody know of a way I can configure or rebuild PHPUnit so that it uses my XAMP...

How to handle deprecated function in PHP

Hi all, I'm new in this site. I want to ask about PHP programming. How do we can handle deprecated function in PHP. I want to redirect it to my new function. As we know, ereg function has been deprecated in PHP 5.3.0 and recommended to preg_match (posix to PCRE). But, when we wrote a lot of code with ereg function, do we have to change ...

PHP - usage of is_numeric() necessary, or can use comparison signs work for all positive numeric cases?

It seems that simple comparison signs >,>= and their reverse components can evaluate if a certain variable is a number or not. Example $whatami='beast'; ($whatami<0)?echo 'NaN':echo 'is numeric!'; Are there cases where is_numeric() usage is necessary for positive values (number >0)? It seems that using comparison signs above would deter...

how to get ordinal position of element in a large json data with php

I have large json data which is contains hundreds thousands elements, now i need to get the ordinal position of an item inside the data with php. what is the best approach to do this rather than having loop because performance is important in this case. Seems PHPLINQ looks promising but performance not so good. Thanks in advanced ...