php

preg_split commas not inside parenthesis

Test string: Organic whole wheat bread, Monterey Jack Cheese (milk, cheese culture, salt), Hormel Natural Ham (salt, turbinado sugar, lactic acid (not from milk) Desired output: Array ( [0] => Organic whole wheat bread [1] => Monterey Jack Cheese [2] => Hormel Natural Ham ) I don't mind if the sub-in...

php check what server the application is running on?

How can I check in a PHP script if it's running in a windows or unix environment? ...

Space bar not working in form fields

I am using a template to build a one page portfolio site. The contact form is acting very strange! I cannot enter space in any of the contact fields. Here is the site: www.cloth2clay.com When you focus in on the message field, it does not allow you to use any spaces. Any ideas? ...

Is there something magical about this? The file always turns to ANSI

I have created a file and saved it as UTF-8 I placed this code: <div class="top_pic"> <img src="<?php echo $this->images_dir ?>image.jpg" alt="doc ao fim do dia" width="632" height="320"/> </div> <div id="conteudo_menu"> <?php echo $this->conteudo_menu ?> </div> <div id="item_list"> <?php echo $this->vinhos_lista ?> </div> ...

Is it possible to execute the procedure of a function in the scope of the caller?

Imagine aFunction() { $foo = 123; // a lot more code } aFunction(); echo $foo; // undefined Is there a way to put the procedure of aFunction into the scope of the caller? ...

how to remove warning messages in php?

hello i have a php code, when i run it, a warning appears in the page how can i remove warning messages? and ignore them ...

XPath to get one level of childnodes

Using DOMXPath::query is it possible to get just one level deep of childNodes? For example if I had a document like: <div> <span> <cite> </cite> </span> <span> <cite> </cite> </span> </div> I would want the NodeList to contain just the spans and not the cites. Should also mention that ...

identical contact forms behaving differently on different hosting accounts

I've never experienced this problem. I have two hosting accounts, one with godaddy, and one with hostgator. There are identical files on these two URLS: http://www.cloth2clay.com and http://www.vitaminjdesign.com/cloth/cloths/ Both websites look the same, but there is one major difference. When filling out the contact form on the sec...

SQL Question ... should I use a Group By???

I have a situation where I need to group data by a portfolio name, then sort through the data and display check boxes. Here's the table structure. Table A -------- portfolio_id portfolio_name Table B ------- file_id portfolio_id (Foreign Key fk_port_id references portfolio_id in table A) file_name Basically Table A links to table B ...

How can I extract the name of a $_POST variable, not its value_

I am building a function that will validate the values in a form. How can I extract the actual name in string form from a $_POST variable? Ex: $_POST['first_name'] = 'Joe'; I now want to grab the string 'first_name' and use it in a function to declare a variable by that name. I know I can use a foreach loop but isn't there an easier way...

Problem with MySQL storage of a Craigslist parse

I'm using MagpieRSS to parse a Craigslist feed. The "title" field is: ***BUYING ALL BRAND NEW BLACKBERRY IN ANY QUANTITY BOLD~JAVELLIN~ONYX (Gramercy) $100000 and I'm using if( preg_match( "/\(*\)*\d+$/", $title, $matches ) ) to figure out the price. $matches[0] should have the price, if I'm not mistaken. However, when I put ...

Should I use a timestamp field in mysql for timezones or other?

MY previous site used DATETIME fileds in MySQL to store all dates/times. On my new site I am adding in timezone capability so I am wanting to store all submitted times at UTC timestamp, I am a little confused now though after reading another post on SO, I read that the timestamp is updated everytime you update the record, if that is the...

PHP: Serve pages without .php files in file structure

I am working on building an internal CMS for clients. Instead of creating a new php file for each page, I am wondering if there is a way to load up a page based on the URL but not a physical php file in that location. So, if I visit www.mysite.com/new-page I would like this to just be a reference to my template, content, etc. rather th...

Error - Web Page Has Expired in PHP?

I have six pages for a registration form in my PHP project. In between any of the page if I press the back button from the explorer bar I get the error: "Webpage has Expired". I am using $_POST to submit the data. I can't understand why this occurs? ...

PHP: Use associative arrays with preg_replace()

In the documentation for preg_replace is says you can use indexed arrays to replace multiple strings. I would like to do this with associative arrays, but it seems to not work. Does anyone know if this indeed does not work? ...

php file upload capitalized filename issue

I have a pretty standard file upload form (that is also writing to a mysql db). It was working fine throughout my testing, then I went and tested a file that was named with all capital letters. The file would not upload. Simple solution I figured, just rename the file before the upload with 'strtolower' but no luck. Also tried strtou...

Move div based on user voting

Hi folks, I'm new here, but I love the site. I checked through the other similar questions, but I didn't see what I'm looking for. I'm a musician, and I've been doing a "song of the day" thing for a while where I write a little song every day. I want to post the songs as <div>s inside <li>. In the divs, I just want a simple mp3 playe...

Searching from comma separated value

This is one of those 'oh my god' moments. The previous programmer in our company has left behind a badly-coded application using PHP and MySQL. One example is that he has stored options for each customer as a comma separated value in MySQL. The entire application is NOT OOP based and so there are repeated references and queries in almo...

cURL without cURL- problem

I wanted to copy files from a remote server, but it seems that the remote host is using session, and needs cookies. well I used this method after defining variables... $url="http://example.com/stamp/stamp.jsp?tp=&amp;arnumber=5255176&amp;isnumber=5255174"; $nn = "\r\n"; $cookies=""; $request = GET . " " . str_replace ( " ", "%20", $url...

Combine multiple files and folders into one file using PHP

I have designed an online editor with which a user can create files and folders on the server. Suppose a user creates the below files and folders. /docs/abc.txt /docs/def.txt /docs/work/assignment.txt I want to write a PHP script to combine the files into a single ZIP file so that it makes it easier for the user to download them with...