php

Is there anyway to access a listing of all PHP variables?

I created a singleton registry to contain instances of all my objects, and I try to unset variables when they are no longer in use. However, I can't seem to ever find all of the variables in use. There always seems to be a couple hundred KB that I can't explain floating around... I'm not sure it this is possible, but can you access an i...

MySQL updating records, but page display not showing new data

I am writing an application to CRUD user details. I kick off the page with a query to the user table - and use the data to populate various form elements in the page (and to check for duplicates). All form submissions submit to the same page. Adding, deleting and modifying records work as expected - but the kicker is that the data displ...

What to do with a community URL style like Last.FM or Wikipedia?

Hi, I'm trying to understand how I should work with characters in URLs, this because I'm building a site where the user can store content and go to the content's page by digiting it's name in the URL. so, something like Wikipedia or Last.FM website. I see in the site, user can write something likehttp://it.wikipedia.org/wiki/Trentemøll...

Error using propel, it can't find build-propel.xml

When trying to create a build using propel-gen (propel v 1.4) I get: [phing] Error reading project file [wrapped: Unable to open /path/to/project/build-propel.xml for reading: ] I can't find a reference to this file in the propel documentation. ...

PHP and Russian Letters

What is happening with Russian letters when sending via PHP request to ... a mail, by e.g.? the "hardcoded" russians letters are displayed properly, but from the Form's textboxex with hieroglyphs: HTML page: <tr> <td style="width: 280px">Содержание работ</td> <td><input type="text" id="workContent"/></td> </tr> PHP page: $WorkCont...

Slashes in MySQL tables, but using PDO and parameterized queries. Whats up?

Alright, so my code to update my database tables is varying flavours of the following: $query = " insert into Comment (Comment, CommentDate, Rating, UserRid) values (:comment, now(), 0, :userrid )" ; try { $db_conn = new PDO('mysql:host='.$db_server.';dbname='.$db_name, $db_username, $db_password ); $db_c...

Encoding $_GET[] values with PHP to make them broswer safe

With PHP, which function is best to be used with $_GET[] values to make them browser safe? I have read up on a few htmlspecialchars() and htmlentities(). Should one of those be used or is there another function that would work better? ...

PHP Mailer - Attachments not sending properly.

When I send a message with a string attachment, the string attachment when opened only gives a 1 and in the email sorce it says --b1_5a1a74831dfa0ce86353d222b95078c6 Content-Type: text/html; name="apperley-invoice-20017.html" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="apperley-invoice-20017.html" MQ==...

Regular expression to exclude chars for a valid URL

hi, I'd like to create a filter which allows almost all chars but without / < > ? = I've read in some site, I shoud use the ^ char inside ranges, but if I try it doesn't work properly: mod_rewrite: RewriteRule ^(user/)([^\<\>\?=]+)([/]?)$ user.php?username=$2 php for validation: return eregi ("[^\<\>\?=/]", $value); how I shou...

Convert large XML file to CSV in PHP

I have a 50MB XML file. I want to convert it to a CSV file, but most methods I have found exhaust the server memory. Is there a good way to do this using a stream method such as XMLreader. ...

Zend Mail - bouncing mails not returning to the specified "Return-Path"

Hi, i'm working on a simple mail list app in PHP using Zend Mail. The idea is that all mail that bounce is redirected to a script which processes them and a report is generated. The script is running ok in direct tests, but I've testing it with fake mail address to test the mail list app, and it appears that the mail is not being redirec...

Obtain the referrer path in PHP

I have a only one .php (root/process.php) file for multiple languages root/en/command.htm root/fr/command.htm root/ru/command.htm and so one. However, for each of commands I have a thankYou.htm in the same folder: root/en/thankYou.htm root/fr/thankYou.htm root/ru/thankYou.htm How do I redirect the page after processing it in...

How do you efficiently connect to mysql in php without reconnecting on every query.

I'm pretty sick of having to rewrite my code every time I learn something new about php (like the fact that mysql connections cannot be passed around in a session as a handle). How do you implement mysql connection in your projects? A lot of people have proposed "connection pooling", but after reading the manual i'm still lost. It's lik...

How do you use a variable in a $_POST[]

I need to iterate through a bunch of dynamically generated fields, but this doesn't work: $population_density = $_POST['$current_location_id']; I have a list of locations with their populations on one page; I need to make it so you can update a lot of them at once. So I made the field names dynamically correspond to the location_id. W...

Convert code from PHP to Ruby on Rails

I'm trying to use geoip's web service for a ruby on rails application. They don't give any ruby demos but this is what they give for PHP. I was wondering if anyone knew how to convert this to work on ruby on rails? I only need the city and the region from the data. More examples can be found at their site at $query = "http://geoip3...

Problem getting value from multi-dim-array

The following code: $options = $value[$i]['options']; print_r($options); outputs the following result: Array ( [0] => stdClass Object ( [id] => 1 [field_id] => 1 [option_name] => I'm a normal user ) [1] => stdClass Object ( [id] => 2 [field_id] => 1 [option_name]...

PHP: Using simplexml to loop through all levels of an XML file

I have a function which uses simplexml to return the first level of nodes in an XML file and write it into an unordered list: function printAssetMap() { $xml = simplexml_load_file(X_ASSETS); $assets = $xml->asset; $html = '<ul>'."\n"; foreach ($assets as $asset) { $html .= '<li id="asset'.$asset->asset_assetid.'"...

Any preg_match to check if a url is a youtube/vimeo/dailymotion video link ?

What's the best preg_match syntax to check if a url is a video link of youtube/vimeo/ or dailymotion? maybe if it's hard, then just to check the domain name. Thanks ...

PHP code to display substring of current URL?

Hello, I want to redirect my browser to a PHP page such that when the page loads, it will display to the user a substring of the current URL. For example, let's say I have a page called substring.php. My browser forwards me to: http://www.example.com/substring.php?oauth_token=123456 Is it possible to write some PHP code that will th...

foreach in class: I cannot return all the ele in arr.

Hello, Well, I keep improving my form generation classes and stuck in returning all the country elements in country_data array. Only first two elements is displaying on dropdown options. Here is dropdown class: //drop down form class class DropDown { function __construct ($form, $field_label, $field_name, $field_desc, $dropdown_da...