php

Return string of html with an embedded php echo statement

Hi there, I'm attempting to return a string of html with an some php code within the html and I'm experiencing a bit of difficulty doing so. Example below: return '//bunch of html here <div id="test"> <?php if (isset($_COOKIE[\"cannycookie\"])) { echo "<a class=\"reply\" href=\"#\" id=\"deletelink-'.$d['id'].'\">Delete</a>...

inserting to xml displays a blank page

i'm trying to insert data into xml using php domdocument. however when i hit enter, it just displays a blank page showing no error. what am i doing wrong? UPDATED: <?php error_reporting(E_ALL); ini_set("display_errors", 1); $xmldoc = new DOMDocument(); if(file_exists('test.xml')){ $xmldoc->load('test.xml'); } els...

PHP doesn't recognise form elements from Javascript

HTML: saucydares.freehostia.com/saucy.php I should just add that while there are no images, the site contains adult themes so isn't work safe. PHP: <?php mysql_connect("mysql4.freehostia.com", sebsal2_db, ""); function him() { $HIMquery = "SELECT dares FROM sebsal2_db.him UNION SELECT dares FROM sebsal2_db.other O...

Is a drupal View useful for this use case

I have a list of nodes that I want to present to the user. The user then picks 3 and I need to remember that decision so I can present them in a smaller list later (your choices list). To present the full list of nodes, I will just use views to get all published nodes. The question is how do I store those 3 choices so I can pull them...

request.POST pylons, getting array like in php

Hi. I have a dynamic form, i must bulid some post array to field witch some id. For example: <input type="checkbox" name="field[124][]" value="1"> <input type="checkbox" name="field[124][]" value="2"> In php i can simply get value and key. foreach($_POST as $key => $value){ if(is_array($value){ foreach($value as $key2 => $value2...

ldap_add: Invalid syntax

I'm trying to add an Active Directory record via PHP. The CN contains a apostrophe (single quote), and I'm trying to find the correct way to escape it. Things I've tried: $dn = "CN=Conan O'Brien,OU=test,DC=test"; ldap_add($link_id, $dn, $attributes); ldap_add($link_id, addslashes($dn), $attributes); ldap_add($link_id, str_replace("'", ...

Http authentication change working directory

What I would like to do is for my users to log in with http authentication. Based on their login username the working directory will be different. I need to use http authentication because I don't want to interfere with the web application (drupal) that is in the users working directories. I also don't the users to have access to the o...

mysql get non existing results with additional conditions

Hi again, using mysql and php, I have two tables, I'm french so the table names may sound weird, but I would like to keep them as originals to avoid errors when testing… "arborescence" (it means categories) "arborescence_domaine" (it means the subdomains for the categories) The aim of this system is to be able to have great control on...

curl_init missing after Macports php5 install

I have a Macports installed version of php5, that is missing the curl extension. phpinfo shows /opt/local/etc/php5/php.ini as the location for php.ini, with one of the additional .ini files listed as /opt/local/var/db/php5/curl.ini The contents of curl.ini: extension=curl.so If I do a locate curl.so I get /opt/local/lib/php/extensions...

What steps should you take to speed up SimpleTest?

I'm writing some testing code on a Drupal 6 project, and I can't believe how slow these tests seem to be running, after working with other languages and frameworks like Ruby on Rails or Django. Drupal.org thinks this question is spam, and won't give me a way to prove I'm human, so I figured SO is the next base place to ask a question li...

Best Practices/How-To for Changing Zend_Session Values with JavaScript

I am migrating an old project to Zend Framework. I have a drop down list that changes filter context. In the old project the onClick event of the <select> list ran a function that made a jQuery ajax call to a php script that essentially updated the $_SESSION variable and then the JavaScript reloaded the page when the response came back. ...

How does PHP uses constants (defines)

Imagine I have this constant in PHP: define('APP_PATH', str_replace('//', '/', str_replace('\\', '/', dirname(__FILE__) . '/'))); When I use APP_PATH in my application, does PHP execute the code (dirname, and the two str_replace on __FILE__) each time or PHP execute the code once and store the result in APP_PATH ? I hope I'm clear eno...

some php to ASP.NET

anyone kind enough to transcribe this php to ASP.NET ?? thank you kindly in advance. jJ <?php if(isset($_POST['data']) && $_POST['data'] != '') { $output = $_POST['data']; $newfile = time() . ".xml"; $file = fopen ($newfile, "w"); fwrite($file, $output); fclose ($file); echo 'file created: ' . $newfile; } else { echo "not...

How do you use gettext when you have link into the translated text ?

I use gettext to translate my web site. It would be nice to have link in text translated but I don't want to write html tags in gettext files because these translations may be used elsewhere. I could create text for web site only (with links) and text for all purpose. I'll have to maintain 2 versions. :-( I could also write a custom p...

Javascript Password Change Form Validation doesn't work on IE8

Hi, got this function to validate two fields from a changing password form and it's doesn't seem to work at IE8. FF, Opera, Safari and Chrome work. function chk_form_pw() { if(document.getElementById('new_passwd').value == '') { alert("<?php _e('Please enter New Password') ?>"); document.getElementById('new_passwd').focus(); re...

How do you organize methods and properties within a class?

Say you're declaring a class with all the bells and whistles - constructor and destructor, public, private, protected and static methods and properties, magic methods, etc. How do you organize all this logically? For instance, do you group things by visibility? Do you alphabetize method names? Do you group magic methods together? Do you...

Filter array by first letter

I'm building a platform. Somewhere in my code, there's an array that looks like this (PHP): $entries = array('p01','p02','g01','g02','a001','a002') I need to write a script that filters the array based on the first letter. For example, asking for those with the starting letter "p" would give me $filtered_entries = array('p01','p02');...

Have an extra /directory/ in the results of a dynamic link on php page

Here I am again. I hate to be a bother but here's another zinger. I have a custom made shopping cart and have some dynamic links in the page that when served up in a browser will replace $name with the product name and $p with the procuct id number. I'm aiming for a link on the page like this: http://www.something.com/buy/ProductName/38...

Upload photos with php without reload

What I want I want to upload a file without without reloading the page, also I want to add the source link for the image to the textarea. So when I push the upload_photo, the image uploads and a link is added to the textarea. I want pure HTML, Javascript|AJAX and PHP. What I have <form action"index.php" method="post" enctype="mu...

Forward Back Records in MySQL with the same DATA in the primary

I have a table that is is sorted 1st by Reminder Date then ID Table Looks like: ID | remind_date 1 2011-01-23 2 2010-02-21 4 2011-04-04 5 2011-04-04 6 2009-05-04 I am using a PHP front end to move forward and back thur the records. I want to have forward and back buttons but i am running into a problem with the 2...