php

JSON, MySQL, PHP - encoding problem

Hello guys. I have been trying to implement an AJAX call on a database returning a JSON file with PHP and eventually met the encoding problem. My database has some char fields with customers' names and, since it is in portuguese, european characters are pretty common. Hence the some results with those characters are returning null via ...

PHP Cannot Write to File - 777 Permissions!

Help! PHP cannot write to any files in my web directory. I don't know why! I have the permissions of the file set to 777, but it is not working! Here is the code in question: <?php if ($f=fopen('test.txt', 'a')) echo 'file opened'; fclose($f); Nothing is being echoed! I don't know why :(.. the userid and gid is 0:0 from the s...

Cakephp Complex Relation Find

I have a little complex Database model on which i am not able to make a proper find user(id, name...) 1 Harsha 2 Jasmine modules (id, name ) 1 Users 2 Restaurants 3 Dishes restaurant (id, name.... ) 1 KFC 2 Pizza Hut dishes (id, name, restaurant_id .. ) 1 Cheese Pizza 2 items (id, module_id, item_id) 1 1 1 (refers to U...

parse content with PHP

hello. I'm trying to use uTorrent webUI API. I think this is a pretty n00b question but there's little documentation about this API on the web, sorry. my server uses file_get_contents($url) and I get the data I want. but in a format I do not understand. for example: { "build": BUILD NUMBER (integer), "label": [ [ ...

How can i get phpunit to run tests from all files in a folder?

From what I've read, it seems like I should be able to set up a folder, e.g. tests/ , put a few files in it with unit test classes, and then run phpunit on that file and have it find and run the tests. For whatever reason, in my installation (on OS X), it thinks the folder tests/ is a file, or so it would seem: $ ls tests test1.php tes...

html tag in php variables

given a php variable $a="<b>hello</b>"; echo $a; //prints <b>hello<b> But I want it to print hello in bold with the formatting. Please tell me what I should do... ...

html in foreach loop

I have a problem with embeded html in foreach loop: HTML: <div class="head"> <div class="wins"> <div class="images"> <a href="#"><img src="images/1.jpg" alt=""></a> <a href="#"><img src="images/2.jpg" alt=""></a> <a href="#"><img src="images/3.jpg" alt=""></a> </div> <div class="Bar"> <a h...

Free (preferably) PHP RTF to HTML converter?

Hi, I am writing a converter for an old db app which contains a large amount of user entered RTF text. Ideally, the RAW RTF should be converted to HTML for display in a browser. I have tried rtfparseclass from PHP Classes, which works ok, but seems to be thrown off but some of the embedded font definitions. For example, raw RTF like {\...

Get Magento config information

I'm trying to get the base url and the media directory from the Magento configuration and I'm trying to use them for a template that has images. I've only gotten as far Mage::getConfig(). I'm not sure what to do next... ...

Wordpress Search Results - Check for custom post type

Hi, I am using the custom post types in my wordpress blog and want to have a different icon for each type of post. <?php if ( is_post_type( 'team' ) ) { echo '<img src="team.png" />';} else { echo '<img src="page.png" />'; }?> But I get following error message: Fatal error: Call to undefined function is_post_type(). Any sugge...

array of special characters to replace in a text, php, json

I have a huge text that i keep getting in a json format. When i receive them in json, for some special characters like ' " &copy, i receive them differently. i am using php and json to convert json into html. for example, i receive ' as \c101d (single quote) " as \c201d (opening quote) " as \c202d (closing quote) I am planning to keep ...

Scripting a MySQL query in Unix using daemon in PHP

I'm trying to make an "at" job work at a given time, for testing purposes I'm using $time but this will be a datetime that I get from a separate MySQL query. In the command line I go like this: echo "mysql -e 'UPDATE admin SET row1=row2 WHERE id=1;'" | at now And I get a "job 36 at 2010-10-28 15:05". in PHP I tried going like this: ...

Decompress SharpZipLib string in php or JS?

I am on a linux server connecting to a webservice via PHP/Soap. The problem is that a method is zipping the response via SharpZipLib. So all I get in return is a garbled string. Does anyone know of a way to unzip this with PHP or JS? Thanks! Update: This is the compressed test data that gets returned: UEsDBC0AAAAIAI5TWz3XB/zi////...

Alternative of html purifier

hi, I want to accept to accept the html input from user and post it on my site also want to make sure that it don't create problem with my site template due to dirty html code. I was using html purifier in the past but Html purifier is not working on one of my server. So I am searching for best alternative. Which is purely written in ...

How to detect certain face on the photo

I was just having a nap and then that crazy idea came into my head. Here it is. We have 2 different photos with face in each. How can we detect if there is the same person on that two photos? Is it possible to do that? If yes, can I do it with Java or PHP? What the way to do it? Any ideas? Maybe each face has a "algorithm" or something...

How do you get the email using facebook api?

I'm using this code but I can't figure out how to get the email from the user. I know you must get special permission from the user but I don't know how. I can get the public data from the user but that's not what I even need. The only thing I need is the email. I guess it's something with this line: $me = $facebook->api('/me'); I h...

Magento Collection Model Filter Modification

Two of my modules are conflicting and it's causing a serious issue, I'm not all that familiar with back-end programming so I've come here hoping someone can help me out. P.S. I did try to solve this on my own for at least an hour or two, learned quite a bit but not anything that was straight forward enough to solve this. I need to modif...

Vote(poll) PHP not working

Hi there, I have a problem with a vote thing in php the code of my page is: $active = '1'; $data = time(); $autor = $_SESSION['username']; $question = $_POST['question']; $contador = 2; $contagem = '0'; while ($contagem <= $resps) { $contagem++;~ $contador++; $question = $_POST['question']; ...

How to enable mod_rewrtie on ubuntu on bitnami machine on Amazon?

Hi Guys, I have created a lamp bitnami server on Amazon. I was wondering how to enable mod_rewrite on it? This is the server that I have http://bitnami.org/stack/lampstack I have tried installing "sudo apt-get install apache2.2-common" then running "sudo a2enmod rewrite" and then editing "/etc/apache2/sites-available/default" and ma...

Complex type as array index

$array[(object)$obj] = $other_obj; PHP arrays only work with indexes having scalar data types like int, string, float, boolean, null. I can't use objects as array index as in other languages? So how can I achieve an object->object mapping? (I though I've seen something like this around here, but don't remember exactly and my search cre...