php

Changing PHP Short tags

So I have the following line... <?=$variable?> Is there a way to change it to long tags without typing a full echo statement? <?php=$variable?> doesn't work I know that <?php echo $variable ?> will work, but is there a shorter way to do it? ...

Get a subset of an array based on an array of keys

I wrote this function to get a subset of an array. Does php have a built in function for this. I can't find one in the docs. Seems like a waste if I'm reinventing the wheel. function array_subset($array, $keys) { $result = array(); foreach($keys as $key){ $result[$key] = $array[$key]; } return $result; } ...

how to prevent duplicate data if data get from DB?

dear all. i have a form that consist of two textfield and one combobox. i want prevent the duplicate entry data from client side. i get combobox data from DB, like: <select id="line" name="faline" > <?php $sql="SELECT `Line_Name` FROM `prod_sch` WHERE `Line_Name` LIKE 'FA %' GROUP BY `Line_Name` ORDER BY `Line_Name`"; if ($sql) { ...

Why won't this simple RewriteRule work?

Hi All, This should be simple but I cannot figure it out. I have this very simple mod_rewrite rule and it just doesn't want to work. This is the entire contents of the .htaccess file. RewriteEngine On RewriteRule ^([A-Za-z0-9-_/\.]+)/?$ index.php?page=$1 [L] If I call the URL domain.com/foo it should rewrite it to index.php?page=foo....

Anyone have experience with PHP and Fannie Mae File Formats (or MISMO)?

Title says it all. I'm working on a mortgage application and we're supposed to use the FNM 3.2 file format but I can't find much in the way of applicable resources. Hoping someone in the community has some experience. ...

PHP MVC question

Given a Controller class and a View class, is it better for the controller to directly assign values to view properties or, is it better to assign values to properties in the controller and then copy those properties to the view when ready to display it? Example Model Class class Model { public $propertyA; public $propertyB; } Ex...

Create a Wordpress plugin that finds text in a post/page and replaces it with links

wordpress , plugins : hi , I want to create website by wordpress but I want to make speacial plugins .. and I made it but there are problem .. _ I have a website and I using it with wiki for contries in the world .. I want from the plugins 'when the visitor open the page for example 'United State' , I want from the plugins to search ab...

Is there have some opensource dating site like plentyoffish.com?

Is there have some opensource dating site like plentyoffish.com? only PHP, Ruby, Java or .Net source is OK. ...

404 error ajax, code works with straight php / html

Hi, so my code works fine by itself, but I'm trying to add some ajax into it. I'm using CI, to do some of the lifting. I don't understand why it's giving a 404 if the code works fine without ajax. Here is the form: <div class="divider" id="contact"> <p class = "header"><a id="contactheader" name="gocontact">Contact</a></p> <...

How to fetch the GET/POST elements in a form without knowing the name of the controls inside the form

I had the list of items. When the user clicks a item, a div is generated with a textbox <input type="text" name="(DYNAMICALLY ASSIGNED VALUE)" /> So user can select multiple items. For each item a textbox is generated dynamically inside the form. When the user clicks the submit button, i want to fetch the GET/POSTED elements. How can we...

How to translate between programming languages

I am setting out to do a side project that has the goal of translating code from one programming language to another. The languages I am starting with are PHP and Python (Python to PHP should be easier to start with), but ideally I would be able to add other languages with (relative) ease. The plan is: This is geared towards web develo...

php, apache & .htaccess: include php configuration file globally

hi, i have a php project which has a configuration file config.php that stores config information like database info, directories, etc. normally we would include this config file at the top of every php page like require_once(".../config.php); however, i have found a way to do this by creating a .htaccess file and include this: php_va...

benefit of calling mysql_close()

Possible Duplicates: using mysql_close() close mysql connection important? What are the benefits of closing the connection using mysql_close() as the last line of your script compared to letting php close it for you? ...

PHP, passing each element in array into function without knowing how many elements in arrray?

This is stumping me.. I am writing components / library functions where it would be used for calling a lot of different functions, so I want it to make an array print out each variable to be passed into the function as an argument, like below but I am pretty sure that this isn't proper syntax.. thanks for any advice $myfunction = functi...

Use wordpress api in parent site

I have the following site structure Parent Site -> blog (wordpress) -> get-recent-posts.php -> index.php I want to display a list of recent posts in the index.php. I am trying to use wordpress api functions in index.php but it is not working. If i try to directly run get-recent-posts.php it shows the posts but if i include it in in...

PHP round off to the nearest 10 ?

I have a data like 93 i want if to become 90 95 i want to become 100 How can I do that in PHP? Thanks! ...

PHP Regex Question

Hi All, So I'm using Wordpress' database object to store things into tables. One of the drawbacks (or advantages, depending on how you look at it) is that it escapes the single and double quote characters so that: ' --> \' " ---> \" What regex can I apply to the output to replace all \' with ' and \" with "? ...

Apache / PHP is serving the wrong content type

I have this PHP file: <?php header('Content-type: text/xml; charset=UTF-8'); ?><?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="hello world example" /> <Content type="html"> <![CDATA[ Hello, world! ]]> </Content> </Module> I would expect it to return a Content-type:text/xml header. What i...

Better site performance: multiple simple mySQL queries or one complex mySQL query later manipulated in PHP?

I am new to web development and am used to extensive use of various data structures in getting things done. I've also heard that having lots of queries is worse than few queries (but that complex queries can be even slower). I'm wondering whether lots of simple queries would perform better or worse than one complex query that is later p...

Problem when sending mail with Zend Mail?

Hello, I'm trying to send an e-mail with ZendMail ( this simple script sums it up ) <?php require_once 'Zend/Mail.php'; $mail = new Zend_Mail(); $mail->setBodyText('My Nice Test Text'); $mail->setBodyHtml('My Nice Test Text'); $mail->setFrom('[email protected]', 'Mr Example'); $mail->addTo('[email protected]', 'Mr Test'); $mail->setSub...