php

Tips about a good class-structure for website? (php)

Hello I'm creating a kind of massive network for users to register and login. I want to try using classes, but I've never used them (expect some mysql-wrappers etc). Could you provide some tips and sample-structure for my project? The idea is to simply have a index.php, which prints the whole page and does all the action. Index.php cal...

Output array of XML to plain XML

I have a script which collects 4 URL's (XML) using CURL and returns an array with 4 items each ocntaining the results of the URL's. Here is the array: array(3) { [0]=> string(41772) "<?xml version="1.0" encoding="UTF-8"?> <statuses type="array"> <status> <created_at>Tue Mar 30 20:58:53 +0000 2010</created_at> <id>11328253513</i...

Best way to fetch remote RSS through authenticated proxy and parse it

I'm trying to get a remote RSS through proxy and parse it. I'm using magpierss, but it doesn't allow reaching internet through a proxy (or I don't know how to do it). I assume the option is to, first, fetch the rss with curl functions, that allows proxy authenticating, but .... are there any class to do this in a easy way, or ... does...

Problem with echoing my array data in PHP

I want to create an array of numbers: 10, 9,8...to 1. But when I echo $numbers, I get "Array" as the output as to the numbers. There is probably a simple thing I missed, can you please tell me. thanks! $numbers=array(); for ($i=10; $i>0; $i--){ array_push($numbers, $i); } echo $numbers; ...

Blogging Infrastructure using Zend Framework?

Hi there folks, I'm researching the prospect of incorporating a blog into my site. Currently, my site is written using the Zend Framework so it's not just a case of using Wordpress and that be the end of it. I was wondering. Has someone already done what I'm thinking of doing and written a blog infrastructure with comments and so forth...

Using css "active tab" technique on single page

I'm building a navigation system using jquery scrollto. I have my navigation menu in a separate file (( navigation.php )). It is included in 5 locations on the first page (( 5 different sections w/ text following each )). I'm trying to figure out a way to have the current "tab" highlight'd. I could hard code the navigation in each locati...

Callbacks in Thrift Asynchronous Functions?

Hi all, In Thrift it is possible to use the oneway modifier to specify a call as asynchronous. Apparently, it's not possible to define a callback, though, to be executed when the execution of the function is completed. It seems that the only possibility I have is to give my Thrift client (PHP) some "server" capabilities, so that, when...

Proper usage of SQLite3 in PHP

What is the difference between: $db = new SQLiteDatabase('name.db'); and $db = new PDO('sqlite:name.db'); Since, I don't understand the big picture here, details are premature for me and the information available online appears to assume certain knowledge I seem to be lacking. Please don't just paste in links to the PHP manual. L...

Good Syntax Highlighter For Self-Hosted WordPress Blog

Hello, I am looking for a good automatic syntax highlighter for self-hosted WordPress blog (not wordpress.com blog). It would be great if the syntax highlighter automatically detects code parts and highlights them. Thanks in advance. ...

zend_barcode in MVC

hi people, i just want an Action to print a barcode image, but i can´t get this working in MVC, i just do the following: public function barcodeAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); Zend_Barcode::render($_GET['barcodeType'], 'image', $_GET, $_GET); } but when I cal...

Optimizing PHP require_once's for low disk i/o?

Q1) I'm designing a CMS (-who isn't!) but priority is being given to caching. Literally everything is cached. DB rows, DB id queries, Configuration data, processed data, compiled templates. Currently it has two layers of caching. The first is a opcode cache or memory cache such as apc, eaccelerator, xcache or memcached. If an entry is ...

How can I protect this code from SQL Injection? A bit confused.

I've read various sources but I'm unsure how to implement them into my code. I was wondering if somebody could give me a quick hand with it? Once I've been shown how to do it once in my code I'll be able to pick it up I think! This is from an AJAX autocomplete I found on the net, although I saw something to do with it being vulnerable to...

Unknown column '' in 'field list'

I am running a sql in PHP query that is dieing with the mysql_error() of Unknown column '' in 'field list' The query: SELECT `standard` AS fee FROM `corporation_state_fee` WHERE `stateid` = '8' LIMIT 1 when I run the query in PHPmyadmin, it return the information without flagging the error EDIT: I apologize for not posting enough...

php date formatting with MySQL SHOW TABLE STATUS

probably missing something simple: <?php $con=mysql_connect('localhost','xxx','xxx'); $db=mysql_select_db('xxx'); $sql = mysql_query("SHOW TABLE STATUS WHERE `name`=\"my_table\""); $foo=mysql_fetch_array($sql); return $foo['Update_time']; // returns 2010-03-31 16:51:06 ?> how do i format this. I tried using date('l jS F Y @ H:i...

Why is my nl2br() function displaying \r instead of a break(<br />)? PHP

When I use the function nl2br($text) it doesn't display the breaks I want it to but instead shows the \r of where the breaks are to be. I am display a confirmation page for a user that shows the detail they entered in the form. (the confirmation code in php) // Confirm success with the user echo '<p>You have successfully posted a a...

Strange text when converting XML array to XML

Im using the answer to this question to convert an array of XML to a single XML output: http://stackoverflow.com/questions/2554671/output-array-of-xml-to-plain-xml Im using the simpler solution of the two there (Marked as the answer) It all works for me, however at the start of the output I get: string(109960) " Can anyone shed an...

php extracting complete url with variables

Hi there, Using Php I would like to extract the current Url of a page including all variables attached to it. $_SERVER['PHP_SELF'] only return the url without the variable . any idea what function I need. example : www.site.com/?v1=xyz&v2=123 using $_SERVER['PHP_SELF'] I get only : www.site.com as opposed to the whole url. using $_GET[...

Is there a better loop I could write to reduce database queries?

Below is some code I've written that is effective, but makes too many database queries. Is there a way I could optimize and reduce the number of queries but have conditional statements still be as effective as below? I pasted the code repeated a few times just for good measure. echo "<h3>Pool Packages</h3>"; echo "<ul>"; for...

How to consume WCF WebServices from PHP?

I have to consume a WCF WebServices but the WSDL contains bindings that PHP doesn't support also. SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport 'http://schemas.microsoft.com/soap/named-pipe' How to bypass this problem? ...

How to strip a GET property from the URL using PHP

I have the following function that get's the current page URL: <?php // get current page url function currentPageUrl() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME...