php

What is the way to manage errors and return JSON?

I have a php application, that, when it encounters an error, will run a function that uses trigger_error() as well as uses the following function to return the error as JSON. $this->returnError('My error'); In some places in the script, multiple errors occur, but only one gets returned, because the returnError() function will stop th...

mod_rewrite help

Using mod rewrite for the first time. Please help me with these rules I'd like my urls rewritten for pages as follows: list.php?city=dallas >>> list/city/dallas profile.php?id=12 >>> profile/zaknuman (username retrieved from db) story.php?id=33 >>> story/there-are-no-ants-in-texas (story title retrieved from db) ...

Open Id implementation in php?

I am considering implementing OpenID on my website and I am having a hard time finding good resources for OpenID implementation in php. So far I have only found RPX but I don't want to depend on third party vendors. I want something similar to SO , can anyone point me in the right direction and can you also tell approximately how much ti...

Limit Flex Web App Upload file formats and size (server script PHP)

Hello everyone I have found this great tutorial, about uploading files with a Flex app, using Php to do the server scripting for us. http://hybridhacking.com/tutorials/uploading-files-with-flex-using-php Its great, but i wanted to know what changes should i do at the ActionScript so that only accepts image files, and if possible to li...

Setting permission for PHP (or I_USER [I'm not sure here...]) to connect to iisweb.vbs

I have been trying to figure out a way to manage our domains at work and easily created a SimpleDNS class, but now I'm on the IIS Server Administration side of it and I'm just lost on what is going on. Here is the PHP code I am running to test it. <?php $cmd = 'iisweb /create c:\websites\examplesite.com\www "Example Domain!" /d www.exa...

Regexp character filter

In my code, I use a regexp I googled somewhere, but I don't understand it. :) preg_match("/^[\p{L} 0-9\-]{4,25}$/", $login)) What does that p{L} mean? I know what it does -- all characters with national letters included. And my second question, I want to sanitize user input for ingame chat, so I'm starting with the regexp mentioned ...

Invalid JSON parsing using PHP

I'm pulling a JSON feed that is invalid JSON. It's missing quotes entirely. I've tried a few things, like explode() and str_replace(), to get the string looking a little bit more like valid JSON, but with an associate JSON string inside, it generally gets screwed up. Here's an example: id:43015,name:'John Doe',level:15,systems:[{t:6,gl...

Cannot run FPDF in PHP Version 5.2.10

The server information says that the PHP version is 5.2.10. Our fPDF works on version 5.3, but not version 5.2.8. The error is always FPDF error: Missing or incorrect image file: What is the problem? Code Snippet: <?php require('fpdf.php'); class PDF extends FPDF { var $aCols=array(); function Header() { //Logo $this...

Handling back button

I have a sign-up form that takes several steps. In one of the steps, they fill up some information, and they select some images to upload. The next step, they see a review of their application. What is likely to happen next is that if the user sees something he doesn't like, he will hit the back button to change what's on the form. H...

Datetime NOW PHP mysql (+ PDO variant)

Thanks for looking. All helpful answers/comments are up voted. In php, you can use NOW() like this: mysql_query("INSERT INTO tablename (id, value, time_created) VALUES ('{$id}', '{$value}', NOW())"); How can I do the same thing in PDO. When I bind like this, I get an error: $stmt->bindParam('...

PHP library for parsing XML with a colons in tag names?

I've been trying to use SimpleXML, but it doesn't seem to like XML that looks like this: <xhtml:div>sample <xhtml:em>italic</xhtml:em> text</xhtml:div> So what library will handle tags that look like that (have a colon in them)? ...

Cannot connect to MySQL 4.1+ using old authentication

I'm trying to connect to a mySQL database at http://bluesql.net, but when I try to connect, it gives this error: Connect Error (2000) mysqlnd cannot connect to MySQL 4.1+ using old authentication I've looked into this, and it has to do with some old password scheme used before MySQL 4.1. Newer versions have the option to use old passw...

Getting certain attribute value in an element with multiple values using xpath PHP

Hi, i'm playing around with flickr API lately and having difficulties in parsing their response to extract the info i need, here is a sample response: − <rsp stat="ok"> − <sizes canblog="0" canprint="0" candownload="1"> <size label="Square" width="75" height="75" source="http://farm3.static.flickr.com/2306/1555710063_d2c1e7e7cd_s.jpg" ...

one class instance

is there a way to prevent the instance of the same class in a PHP script? $user = new User(); $user2 = new User(); // I want to catch another instance of the user class and throw an exception I have tried creating a static variable and manipulating it with a static function: User::instance() but that doesn't stop me from doing: ...

What language should I learn to develop Cross-Plataform software, coming from PHP?

Hey guys, I've been "programming" in PHP for about 3 or 4 years I think, and I think I'm pretty good at it already, so decided to move on to something more complex. I understand that PHP is too flexible (you don't have to declare the type of a variable, for example) and that I'll have to get used to code in such ways. So basically I wa...

help in php file_get_contents

i have this file C:\\xampp\htdocs\exact\sample_pie.php that contains a graph. here's the code: <?php include("phpgraphlib.php"); include("phpgraphlib_pie.php"); include("connection.php"); $graph=new PHPGraphLibPie(400,200); $link = mysql_connect('localhost', 'root', ''); mysql_select_db('exact'); $querypa = "SELECT COUNT(nature) FROM ...

Checking Model relationships in CakePHP

Is there a way to check CakePHP's model relationships? One model is saving twice on a table and I really suspect there's something wrong with my relationships. Problem is I have a lot of tables so it's really a pain. I'm wondering if there's a more sure and easy way of doing this maybe automatically? Thanks in advance! ...

tiny_mce affect all the text area in my page

hi i downlaoded a tiny_mce folder and implemented it in my page. it's work fine, My problem is that all the textarea in my page looks like tiny mce , i want only one textarea looks like tiny mce and left of all in normal textarea . what will i do to do this??? Please replay urgently Thanks in advance........... ...

Numeric String (arbitrary size) -> Multiple Integers

I'm running into a problem because my database has BIGINT data (64-bit integers) but the version of PHP I'm running is only 32-bit. So when I pull out value from a table I end up with a numeric string representing a 64-bit integer in base 10. What I would ideally like to do is use the 64-bit integer as a bitmask. So I need to go to ei...

PHP Check for NULL

Here is the below Code: $query = mysql_query("SELECT * FROM tablex"); if ($result = mysql_fetch_array($query)){ if ($result['column'] == NULL) { print "<input type='checkbox' />"; } else { print "<input type='checkbox' checked />"; } } If the values are NOT NULL i still get the uncheked box. Am i doing something wrong from a...