php

ZF: Login Form Validation

WHat's the best way/code in Login Form (Zend_Form) to display error message 'Login/password incorrect'? I slowly begin to understand, that setting $this->setErrorMessage('Login/password incorrect') in form/init() is not enough and I somehow have to involve Validators to be able to see the message I set. To which object should I bind th...

Zend_Session lost when using regenerateId()

I've had this problem in a couple of ZF applications now and it's very frustrating: Near the top of my bootstrap I have the following two lines Zend_Session::start(); Zend_Session::regenerateId(); My application requires authentication using Zend_Auth and uses default session storage for persisting an identity. At random the session ...

Fast unsafe easy PHP key-value database?

I need to store JSON strings against string keys (that should be like 255 characters long). Only querying by key is necessary, so basically just a persistent hash table. It doesn't need to be very safe to write to, but should be kind of fast (few thousand writes per second on single box). If two processes happen to try to write the same ...

CakePHP Multiple Tables For Model

Can a model have multiple tables in CakePHP? ...

mysqli for php on Ubuntu 8.04 LAMP stack

Does anyone know how, on Ubuntu 8.04, with PHP 5 and MySQL 5.0, to enable/install the mysqli package/extensions? Preferably I'd like to preserve the existing installations, but, if necessary, I'll reinstall from scratch. I realise it's not, technically, programming-related but, I think (at a stretch, maybe) it's programming-enabling? h...

MySQL - pass database field through PHP function before returning result

The following code from http://php.morva.net/manual/en/mysqli-stmt.bind-result.php shows a mysqli query being prepared and executed. while ($stmt->fetch()) loop looks like it is generating the result resource. Can I change this to include a call to a function e.g. while ($stmt->fetch()) { foreach($row as $key => $val) { ...

How can I generate a screenshot of a webpage using a server-side script?

I need a server-side script (PHP, Python) to capture a webpage to a PNG, JPG, Tiff, GIF image and resize them to a thumbnail. What is the best way to accomplish this? See also: Web Page Screenshots with PHP? How can I take a screenshot of a website with PHP and GD? How might I obtain a Snapshot or Thumbnail of a web page usi...

What's the reason for cookies mysteriously reappearing?

I'm developing a web application using a cookie to store session information. I've manually deleted the session cookies because I'm working on another part of the code where I don't want a login session. However, after a couple reloads of the page, the session cookie mysteriously reappears, including an earlier cookie that I had only set...

Can I write my own mySQL functions to use in mySQL queries?

Can I write a custom function that I can call when making mySQL queries eg. My database table has fields 'filetype' and 'filename'. I want to perform a function on filename before returning the result. $query = "SELECT filetype, MY_FUNCTION(filename) FROM table.."; $result = mysql_query($query); return $result SO $result now has the ...

How do I write, compile and use a user defined function for mysql running on Windows 2003 server?

I am using - MySQL v 5.0.22, PHP v 5.2.0, Windows 2003, Apache. My skills - Basic PHP knowledge, Basic MySQL. What is the best way for me to write and use a mysql user defined function in my PHP scripts? ...

Overcome Encoding Problems with PHP, SoapServer, UTF-8, and non English Characters?

I'm having problems getting PHP to play nicely with SoapServer + UTF-8. Anytime anyone sends a Soap Request with non english characters (i.e. funny quotes, accented characters, etc) the SoapServer throws an exception saying "Bad Request." I've tried decoding the request with utf8_decode and even HTML Special Characters encoded the text. ...

PHP @exec is failing silently

This is driving me crazy. I'm trying to execute a command line statement on a windows box for my PHP web app. It's running on windows XP, IIS5.1. The web app is running fine, but I cannot get @exec() to work with a specific contactenated variable. My command construction looks like this: $cmd = ($config->svn." cat ".$this->repConfig...

Retrieving current Active Directory username from PHP

For a website on the Intranet with all the IE security settings setup. I want to retrieve the current AD username that the user is logged in with. I don't need to authenticate because I am assuming that the person on the computer has already gone through the process. Is this even possible? I've seen a lot of NTLM related stuff that sho...

reverse string php

What would be the best way to reverse the order of a string so for instance, 'Hello everybody in stackoverflow' becomes 'stackoverflow in everybody Hello' any ideas ...

array_flip certain keys

What would be a good way of fliping key 1 with key 2? // original Array ( [0] => Text1 [1] => World [2] => Hello ) // after Array ( [0] => Text1 [1] => Hello [2] => World ) Any clues. Thanks ...

Split String into Parts PHP

Have the following string i need to split. $string = "This is string sample - $2565"; $split_point = " - "; One: I need to be able to split the string into two parts using a regex or any other match and specify where is going to split. Second: Also want to do a preg_match for $ and then only grab number on the right of $. Any sugges...

how to get parameter like mysite.com/myaction/#someanchor with php and javascript

For example I hide comments by default. So if I find #comments I will be know that I need to show them up. Is that possible to catch with php or javascript on page load? ...

How do I do an SQL join with a CSV file in php (drupal specifically)?

Hey guys, here is my problem. I am writing a Drupal module. A user uploads a CSV list of e-mail addresses to a server in a form. I need to do a JOIN on my database to get a list of unique addresses from the CSV file and the DB (No, it is not for spam :). How would I turn the uploaded CSV file into a format that I can do an SQL join on i...

Need a simple hash in PHP

I need to create a simple hashing method for passing some data in a URL. It doesn't need to be very secure, it just shouldn't be obvious to most people. The hash needs to contains the numerical id of the sender and the id of the recipient and I should be able to decode the data after reading the appended hash. Any ideas? I'd like the h...

Using PHP variable variables in SQL quiery

Hi, sorry for this question to be a "can you fix it" one, but this little bit of code has been confusing me for a while now. I'm basically making a table with a bunch of rows and columns and in each one I have a slightly changing SQl query. To make it a bit easier instead of typing all that out I made this bit of script but it is starti...