php

Object and Ternary Operator PHP

Hello, I wanna make use of the Ternary Operator with an object. if($msg == 'hello'){ $o->setHello('hello'); else $o->setHello('bye'); How could I do that? Thanks ...

Zend_Form radio element

Below is sample code to create a radio button element with Yes/No options in Zend_Form. Any ideas on how to set the required answer to Yes, so if No is selected, it'll fail validation? The code below will accept either Yes or No. $question= new Zend_Form_Element_Radio('question'); $question->setRequired(true) ->setLabel('Are you sur...

WordPress: Useful plugins for building a user manual?

What are some recommended WordPress plugins that make building an online user manual more effective? I've been browsing the plugin directory, but was wondering if anyone has already been down this path and could make some recommendations. Edit: Doh! Using a wiki didn't even occur to me until these responses! I started building a site us...

How to make DOMDocument write standalone=yes in PHP?

I'm using PHP5 to create XML files. I have code like this: $doc = new DOMDocument(); ... $xml_content = $doc->saveXML(); The problem is that created XML code starts with a root node like this one: <?xml version="1.0"?> But I want it to be like this: <?xml version="1.0" standalone="yes" ?> I guess I need to call some function on ...

Detecting https requests in php

The problem that I am having has to do with the need to keep some urls of a website protected by https and the rest kicked to http. Normally, you have $_SERVER['HTTP_HTTPS'] or $_SERVER['HTTPS'] (depending on your flavor of Apache). You also can check the port - it's 80 for normal traffic and 443 for https. My problem is that the cert...

I have installed Zend Framework and need to set up include path in PHP?

I have dumped Zend Framework files in "home/hotbuzz/public_html/include/zend/" My hosting : linux I want to load it in my script. Whenever I load I get this error. Some info: I asked about my Zend, to hosting guys they said its located in "usr/local/zend" But I want to use this home/hotbuzz/public_html/include/zend/ I had added ...

double dimensional array value from php

Dear All I have a PHP file going to write a two-dimensional array in javascript: <?php print "<script language='javascript'>"; print " extra[0][0]=new Array(1,'Bob',12);"; print " extra[0][1]=new Array(2,'Alice',18);"; .. // need to assign the extra[1][0],extra[1][1] so on. print "</script>"; ...

Limit a MySQL query to an even number of results (using PHP and mysqli)

Hi, I have a bit of PHP code which I need to return an even number of results from a MySQL database. I'm using the mysqli extension to execute my query. My code is approximately this at the moment: //assume we already have a database connection $query = "SELECT id FROM movies WHERE publish = 1 AN...

Possible to set max rows in MySQL table?

Hello! I have a question about tables in MySQL. I'm currently making a website where I have files for people to download. Now I want to make a table in MySQL that will store the latest downloads, like if someone downloads file1.zip then it will add a row in the table with the filename and date, so that I can show on the front page "Most...

After a RewriteRule to a PHP script, do an internal redirect from within the PHP

Hello, I have some mod_rewrite rewrites that correctly redirect the URLs to a script. From within the script, I want to go to a different file without causing another request/changing the URL. I have experimented with Location and meta refreshes but they are not as smooth as desired. Is there a way to change to the script or even retur...

Help with include function

Im trying to make a simple template system in PHP. I'm new to PHP, so it's nothing serious. I have some problems though: A regular include works: $variable = "test"; include("templates/news.html"); But this won't: This says $variable is undefined: $variable = "test"; getTemplate("news"); The Function: function getTemplate($tpl) ...

interactive console for Ruby, PHP

How do you start the Interactive Console for ruby and php ...

Can anyone explain this .ASP aka VB "Regex.Replace" function so that I can do it in PHP?

Hi, The following code is visual basic, .NET, ASP... all of the above? Can anybody tell me what these two "Regex.Replace" functions/methods will leave me with when "strCookies" is equal to the block of text below the two Regex.Replace functions? I believe the idea is simply to capture the "sessionid" code and then the "cadata" code with ...

PHP/RegEx - Logic for prepending table names

So I'm trying to build a script that automagically prepends valid column names with its appropriate table prefix (e.g. "t." or "r.") $t_columns = array('id', 'name', 'label'); $r_columns = array('related_value'); INPUT: id > 1 AND (name = 'Hello' OR label IN ('World', 'Planet name AND label')) AND (related_value > 1 AND related_value...

How to get products from a particular category in magento ecommerce

I'd like to get a list of random products from the same category as the current product for displaying within the product view - so far all I've dug up is http://stackoverflow.com/questions/272818/magento-products-by-categories Does anyone know how to do this? ...

Is there anywhere to find a list of what I can set for the form with Zend Framework

I am just starting out with the Zend Framework and I am a little confused but getting there. Anyway I have been reading the documentation for *Zend_Form* and was wondering about setting values for the form such as this: $form->setAction('') ->setMethod('post') setAction and setMethod were the only two options given and I was wond...

PHP Application Updates

I am writing a web app in PHP, and it has come time to build an update system, one of the requirements is automatic updates, how should I do this? I want to do it without a cron, so I'm going to have to check for updates when requests are made to the system, should I do this only when an admin, with significant privs, logs-in, I think t...

Where are $_SESSION variables stored?

The title kind of speaks for itself, are $_SESSION variables stored on the client or the server? ...

Client side report printing from PHP web apps

I was looking for a solution for client side printing of reports and pre formatted forms from a PHP web based app. Note that these are not printing of HTML pages. Rather nicely aligned fixed formated Receipts, Order Forms, Ledger etc. Something that I have though of. Using PDF: Is there a simple one click way to print the report from c...

Simple script to replace Apache's mod_autoindex with a user-friendly directory listing

The Apache module mod_autoindex generates "directory indexes" that show users a crude hyperlinked list of the files and directories inside a directory (when there is no index.html or other DirectoryIndex file). I have a directory on an Apache webserver where I want to provide an automatic directory listing, including the full filenames,...