php

How to find similar/related text with Zend Lucene?

Say I need to make searching for related titles just like stackoverflow does before you add your question or digg.com before submitting news. I didn't find a way how to do this with Zend Lucene. There are setSlop method for queries, but as I understand, it doesn't help. Is there any way to do this kind of searches? ...

Count Records Returned MySQL Doctrine

Hi, How do I check the number of records returned from a search of my MySQL database with a statement like this: $searchKey = 'Something to search for'; $searchResults = Doctrine::getTable('TableName')->createQuery('t')- >where('columnName LIKE ?','%'.$searchKey.'%')->execute(); ...

PHP page load seems to be requesting itself and misinterpreting the result

I'm working on a messy PHP page by another developer and I was analyzing the resource view in the Webkit developer tools and noticed that the page (index.php) makes an HTTP requests for itself and then interprets the results as an image despite it being sent with the text/html header. Because of this it throws the warning: Resource i...

Is there a glitch with opendir/readdir?

Here is my PHP code: <?php // Enumerate the directories in styles $styles_dir = 'styles/'; if($handle = opendir($styles_dir)) { while(FALSE !== ($file = readdir($handle))) { echo $file . '(' . is_dir($file) . ')<br>'; } } ?> Here are the directories in styles: And here is the output: .(1) ..(1) forest() indus...

create class directly after a property field?

in java you can create an object directly after the property field like this: but it seems not working for php: class Test { public $object = new Object(); } you have to create it in the __construct() and assign it to the property? thanks ...

Undefined Variable? But I defined it...

Well before anyone claims that theres a duplicate question... (I've noticed that people who can't answer the question tend to run and look for a duplicate, and then report it.) Here is the duplicate you are looking for: http://stackoverflow.com/questions/2481382/php-claims-my-defined-variable-is-undefined However, this isn't quite a du...

Upload Photo To Album with Facebook's Graph API

Hello All, I'm trying to familiarize myself with Facebook's new Graph API and so far I can fetch and write some data pretty easily. Something I'm struggling to find decent documentation on is uploading images to an album. According to http://developers.facebook.com/docs/api#publishing you need to supply the message argument. But I'm n...

PDO::PARAM for type decimal?

I have 2 database fields `decval` decimal(5,2) `intval` int(3) I have 2 pdo queries that update them. The one that updates the int works ok $update_intval->bindParam(':intval', $intval, PDO::PARAM_INT); but I can't update the decimal field. I've tried the 3 ways below, but nothing works $update_decval->bindParam(':decval', $decval...

How can you pass GET values to another url in php? GET value forwarding

Ok, so I'm using Jquery's AJAX function and it's having trouble passing a URL with a http address. So I'm hoping to "get" the GET values and send them to another URL — so: a local php file begin passed GET values, which in turn forwards the GET values to another url. Maybe curl is the answer? I don't know. It's got to be a very short an...

MVC: models interacts with the view?

i know that everything is going through the controller. but i often read articles that says something like this: user interacts with the view controller asks the model to change its state model notifies the view when its sate has changed i dont get the 3rd one. why saying that the model notifies the view, when it actually is notifyi...

problem with codeigniter using odbc database driver

i’ve run into a curious problem with codeigniter's odbc driver. i’m connecting from a linux machine to an MSSQL 2008 machine using FreeTDS. while i get that the ‘num_rows’ function always returns -1, and that is fully a database/driver issue - for some reason when i try to create a ->result(), the whole application crashes (error 500, s...

Strange problem with PHP and sessions

So the basis of this page is I set a session value when the page loads, and clear it on any other page they visit. Then the page can make an ajax call to download a file. If the session value matches the value I pass through the URL I allow them to download the file. If not I return a 404 error. I was having some weird issues, so I r...

Problem with PHP/Java bridge.

I am using Tomcat 6. I am running a php script using the JavaBridge. I get the following error when I run my code. Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\apache-tomcat-6.0.26\webapps\JavaBridge\xxxx\xxxxx.php on line 534 Please help. ...

Forget late static binding, I need late static __FILE__ ...

I'm looking for the get_called_class() equivalent for __FILE__ ... Maybe something like get_included_file()? I have a set of classes which would like to know what directory they exist in. Something like this: <?php class A { protected $baseDir; public function __construct() { $this->baseDir = dirname(__FILE__); }...

How do I set the socket timeout in PHP?

I need to set timeout on client.recv in TCP server. ...

How to build a url of a GRAVATAR image from a given email

There is a simple way with php, a simple script or URL manipulation to build a URL for the gravatar image corresponding to an email? Ex. http://gravatar.com/avatars/[email protected] and this return a jpeg or png image. If there is no simple way like the example, what is the easiest way you know to resolve a url of ...

Various way to send data to the web server

Client Environment : Windows XP , Internet connection Available, PHP Not installed. Server Environment : CentOS , Internet connection Available, PHP , MYsql installed. Data are stored in files at client machine , suggest better ways to send data fetched from the file to the server. Normally i would be using HTTP request using Curl to s...

Can you make a PHP function recursive without repeating its name?

It's always bugged me a recursive function needs to name itself, when a instantiated class can use $this and a static method can use self etc. Is there a similar way to do this in a recursive function without naming it again (just to cut down on maintenance)? Obviously I could use call_user_func or the __FUNCTION__ constant but I would...

I'm building a javascript app, I need a lightweight php script to interact with a database and javascript using json.

My app is a very complex game that uses json objects to store its execution state (aka save games). I'm looking for a nice database script that can talk json and interact with javascript via ajax. ...

problem in showing an img open from zip archive

iam get the img date from the zip archive by getFromIndex() and the date like that (this the first line of text appearing) ‰PNG ��� IHDR���@���@���ªi know how i can makke appear iam used $im = imagecreatefromstring($data); if ($im !== false) { header('Content-Type: image/png'); imagepng($im); imagedestroy($im); } but ...