php

PHP what is the best way to handle a variable that may not be set?

I have a foreach loop, that will loop through an array, but the array may not exist depending on the logic of this particular application. My question relates to I guess best practices, for example, is it ok to do this: if (isset($array)) { foreach($array as $something) { //do something } } It seems messy to me, ...

Absolute beginner regex question

I'm using PHP 5's preg functions, if it makes a difference. Consider the regular language matched by the following regular expression. ([^{}] | {[0-9a-zA-Z_]+})* The language consists of strings of any number of characters, with special embedded tags marked off by left and right curly brackets, which contain a string of one or more a...

What PHP extensions are preferred? And what about Security preferences?

If you are to install PHP on IIS, what PHP extensions would be good to be installed along with the ones that come by default with PHP? Also, any security extensions/configurations preferred usually? I am thinking Fast CGI, CURL and GD library are required ones. Any other suggestions? I am installing it for a friend, and he asked me to ...

Scraping Google Search Results in PHP

I would like to get the links from the search results. Can someone please help with with the regular expression to do this? I've got this, and it doesn't work: preg_match_all("/<h3(.*)><a href=\"(.*)\"(.*)<\/h3>/", $result, $matches); ...

How to indent text in a select drop down menu using PHP & CSS? [REPHRASED]

I asked a similar question earlier but I'll ask it again in a different way. How can I indent categories and endless sub categories that I have in a select drop down menu using PHP & CSS? Here is my PHP code. while (list($id, $parent_id, $category) = mysqli_fetch_array($r, MYSQLI_NUM)) { // Add to the select menu: echo '<optio...

PHP: Custom parameters for mail command?

I use mstmp to send mail from various smtp account. Using PHP's mail command it sucessfull sends mail from mstmp using the default account. However, I want it to let me specify which smtp account to send from. Using mstmp you do that with the following command: msmtp --account=svh where svh is the smtp account you name. More on msmtp ...

Jquery ajax responsed content does not write into the html form

HTML code : I echo this content in php file, In result i get only the 'Contact Us' Remaining part does not display the html form <div > Contact Us <form name="profile" action="" method="post"> Name : <input type="text" name="fullname" id="fullname" /> Email : <input type="text" name="email" id="email" /> Mobile : <input...

Authorize.net payement transaction

I have connect Authorize.net using direct connection. Currently we have used Visa and American Express for payment . For adding this two feature "payment for MasterCard and Discover" we have need to do some changes in code or not? ...

PHP: How to get sum of elements of 2 dimension array ?

I want to get total of elements of each row at the end of that row and total of elements of each column at the end of each column. For Example: I have an array with digits values like this: $twoDimArr = array( array("1" , "2" , "3" , "4"), array("1" , "2" , "3" , "4"), array("1" , "2" , "3" ,...

Parsing xml data in an order using xquery

I have a xml file like this <?xml version="1.0" encoding="UTF-8"?> <gallery > <gallerydata> <galleryname> Home </galleryname> <createdat> 14/8/2010 4:53 pm </createdat> </gallerydata> <gallerydata> <galleryname> School </galleryname> <createdat> 13/8/2010 5:19 pm </createda...

How to properly check if an html textbox is empty

I always get the undefined index notice, when I run this on wampserver. Tried doing some research before going here, and I integrated the code into this, but still no luck. Please help. <?php if(!empty($_GET['lurl']) || ($_GET['lclass']) || ($_GET['lnotes'])) { $url=$_GET['lurl']; $clas=$_GET['lclass']; $notez=$_GET['l...

Ensuring uniqueness of additions to MySQL table using PHP

I'm trying to create a page that tracks some basic user statistics in a database. I'm starting small, by trying to keep track of how many people come using what User Agent, but I've come across a stumbling block. How can I check the User Agent being added to the table to see if it is already there or not? ...

Wordpress get category main name

So if I'm on a subcategory page...how can I get the name of the main category? So let's say I'm on site.com /my-category/my-subcategory/ so how can I get "my-category" ? I don't want to parse the url :) cuz' I think wordpress has a built in function or smth. Best Regards, ...

Eclipse output to WAMP webserver www folder

I have an eclipse workspace folder. I want to store all the different projects I am working on over here. Now I am working on a PHP project and have WAMP installed. Is there some way to configure eclipse such that it outputs my project files to the server's www folder. I don't want to create my workspace in the server's www folder, for ...

Image Preloader via JSON, JQUERY, PHP

Hi there, im attempting to make a auto preloader via php an JSON my reason being no other preloaders suit my purposes at this time. Im developing off a WAMP installation with php version 5.3.0 an apache version 2.2.11 an using the following php code: $rootDir = dirname(__FILE__).'/..'; $imgdir = opendir($rootDir.'/images/'); $i=0; whi...

php forum type flowing website

I have data in a sql database that'd I'd like to display on a simple website. The data has an initial question ID "IntQID", which is an auto increment field. Every post has an IntQID. There is another field called "ResID", which is the response ID for a post that is responding to a question. The only data that has no ResID is the initial...

Serialization of objects and fatal error

Can anyone explain me, why in the session in this case we get the object with 2 properties? set_error_handler('my_error_handler'); session_start(); $obj = new myclass(); $_SESSION['obj'] = $obj; $a->b(); class myclass { private $a = 1; private $b = 2; public function __sleep() { return array('a'); } } ...

PHP Performance Measurement

How can I benchmark certain peices of code in PHP? I can use timers to calculate the differences, I'm just not sure if it is the best solution out there. ...

php simplexml get object variable start with number

Hi, When I parse an rss file with SimpleXMLElement, I get this object : object(SimpleXMLElement)#307 (1) { [0]=> string(39) "http://workspace/wordpress/hello-world/" } $var->0 doesn't works. I don't know how to do it :( thanks. ...

using PHP in iphone

Hey friend as you know I am new in iphone I didn't know any think about can anyone help me. Can I use PHP in iPhone for storing music file And get get this file again when ever I need this any one who can help out this condition or give some hint to solve this Previously I also put one question about this.But it is with the cloud serve...