php

HTML Data exceeds field length after being hex-sanitized

The problem is you can't really tell the user how many characters are allowed in the field, because the escaped value, obviously, has more characters than the unescaped one. I see a few solutions, but none looks very good: One whitelist for each field (too much work and doesn't quite solve the problem) One blacklist for each field (sa...

PHP $_GET problems with www.example.com/folder/file?id=2 type URLs

I'm changing my site to show friendly URLs like this: www.example.com/folder/topic Works fine! But when I add a parameter to the URL: www.example.com/folder/topic?page=2 $_GET stops working. It doesn't recognise the parameter at all. Am I missing something?? The parameter worked fine before using full URLs. ...

Best way to use sessions with MVC and OO PHP

I've been working with sessions, MVC design and object oriented PHP. Where should I save or retrieve data from a session? I would like to retrieve it from within methods so I don't have to pass the data to the methods. Whats the best practice? ...

What is the default time after which an HTTP request is deemed to have timed out?

For PHP, what is the default time after which an HTTP request is deemed to have timed out? I'm using the PECL HTTP extension to make HTTP requests. I can set a timeout limit when making a request, however I'd like to know what the default is if nothing is explicitly specified. I've hunted through the PHP manual to no avail. I'd apprec...

Standard connection libraries for MySQL, MSSQL, and Oracle in PHP

Hello, I'm looking for a standard way to connect to databases in PHP. We've all been there - first start with some rudimentary code to connect/query/iterate/insert/disconnect, then the code grew as the program grew, and it ended up with a mess that's hardly reusable. I know there are many PEAR, PECL, and other PHP libraries/classes out...

Integrating AJAX and PHP

Hello, I've been writing PHP web applications for some time, and have come across very nice Javascript frameworks, such as JQuery, ExtJS, Scriptaculous, etc. I can't say the same about the PHP side - I always coded that part of the client-server dialog from scratch. I've used CodeIgniter (http://codeigniter.com/) and it is nice, but do...

What's the maximum number of keys for an array in php

I'm writing a php script where I call $lines = file('base_list.txt'); to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run print_r($lines); exit; the array only contains 7280 elements. So I'm curious, WTF? Is there a limit on the amount of keys an...

How do I capture PHP output into a variable?

I'm generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. I also want to be able to show the user the XML before hand. The code is sorta like the following in structure: <?php $lots of = "php"; ?> <xml> <morexml> <?php while(){ ?> <somegeneratedxml> <?php } ?> <...

Which is fastest in PHP- MySQL or MySQLi?

I'd like to know if anyone has any first-hand experience with this dichotomy. A few blogs say the mysql extension is faster than mysqli. Is this true? And I'm only asking about speed. I know mysqli has features that are not present in the older extension. ...

Authenticating in PHP using LDAP through Active Directory

I'm looking for a way to authenticate users through LDAP with PHP (with Active Directory being the provider). Ideally, it should be able to run on IIS 7 (adLDAP does it on Apache). Anyone had done anything similar, with success? Edit: I'd prefer a library/class with code that's ready to go... It'd be silly to invent the wheel when some...

Updating a XML file using PHP

What is the easiest way to update a single attribute in a XML tag using PHP without rewriting and saving the file? Any way to do this just using regular DOM stuff? ...

Best way to document AJAX + PHP code?

Hello, I have always been for documenting code, but when it comes to AJAX + PHP, it's not always easy: the code is really spread out! Logic, data, presentation - you name it - are split and mixed between server-side and client-side code. Sometimes there's also database-side code (stored procedures, views, etc) doing part of the work. T...

Lightweight web app server for PHP?

Hi, I'm doing PHP development. And coming from a Rails background, I'm looking for a like-for-like replacement for Webrick in PHP. Is there such a light weight server? Something with minimal configuration and installation effort. Apache is actually fine. But I would like to know if there're other options. Or do most of you use Apache? ...

Stick with PHP or learn Ruby (on rails)

Hi, I am a CS student and I wanted to get some more experienced folks' opinion on the following: I have a strong background in the curly bracket languages, particularly C and Java, and have been working with php for about a year now and again. I am also currently interning at a PHP shop. My goal is to hopefully get a job in web develop...

Setup multi languages wordpress

I need to setup a blog using wordpress engine but i need it support multi languages (3 languages), currently i am thinking of using custom field to identify the language of current post though i knew thats not a best practices, does anyone has better suggestions? ...

Most efficient way to index a returned array?

function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax error in PHP. What's the most efficient way to directly obtain an element from a returned array without assigning the result to a temp variable? ...

Query Parse error in shopping kart application

In my shopping cart app, I execute a query using: 44: @mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)"); But when I view the webpage, I get the following error: Parse error: parse error, unexpected T_STRING, expecting '{' in H:\Program Files\EasyPHP 2.0b1\www\beta\cart.php on line 44 ...

PHP Libraries: SVN Access

Are there any decent PHP libraries available for accessing SVN repositories? Right now I just have some scripts executing commands to the command line and parsing the feedback, I'd love to find something less dependent on the command line and more tightly integrated. Any ideas? ...

Converting mysql TIME from 24 HR to AM/PM format

Hi, I want to display the TIME field from my mysql table on my website, but rather than showing 21:00:00 etc I want to show 8:00 PM. I need a function/code to do this or even any pointers in the right direction. Will mark the first reply with some code as the correct reply. ...

Does anyone write really long, complex php apps, and if so, what is your problem domain?

It's hard for me to imagine a php script that is more than a few hundred lines of code. It seems that, for a non-persistent environment, web-based scripting is usually done is small chunks and used for the purpose of delivering a portion of a website to the end user. I'd like to know if people are developing any type of large, or persi...