php

[PHP] run query after session expire

Hi all, i need a php code that will run a query after a specific session is going to expire, if(!isset($_SESSION['test'])) query; something like that but does work with session expire, Thanks ...

Is there a way to catch all keyboard input in a browser?

Is there a way to catch all keyboard input in a browser? Im guessing it would have to be JavaScript. My problem is that I have a USB Bar Code Scanner which the computer treats as a second keyboard. I dont want the user to have to click on the input box for bar codes to be entered in it. But I also want them to be able to hit key short c...

Do you prefix your classnames ?

Hi everybody, Simple question : do you prefix your PHP classes (for example your library classes) with the name of your company ? Example : Zend prefix everything with "Zend_", but that's normal because this is a framework (so they want to avoid conflicts). Should I do the same for the library classes of my company ? Will I ever get co...

Sphinx: Using SetGroupBy to sort groups using aggregate functions

I want to group-by one attribute, then sort those groups using the min- or max-value of a different attribute, in either ascending or descending order. We've defined a source with a bunch of attributes including: sql_attr_uint = CategoryId sql_attr_str2ordinal = SortableName Without grouping, we can sort results using SortableNam...

How is the force reload of javascript/css done in Symfony?

After reading this thread: http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files I would like to know if there is any built-in function or easy way in Symfony that automatically forces a reload by appending a random querystring or timestamp to the link when it has discovered th...

How do I send emails with Arabic content via PHP's mail function ?

I'm having a challenge with sending emails with arabic content using PHP's mail function. Let's say I have this simple arabic string: بريد I've tried several ways to utilize the headers, but the emails content all still end up with something like: X*X1X(X1Y X/. However, the email subject is correctly encoded if I use arabic characters ...

Mass of text, cherry pick email addresses

Hello, I have a large file full of text and in there are some email addresses. Which php regular expression function would return an array of email addresses it could find? So far I have <?php $pattern = "/^[^@]*@[^@]*\.[^@]*$/"; if ($handle = opendir('files')) { /* This is the correct way to loop over the directory. */ while (fal...

Interface for blog via desktop application

I was unsure as to how to title this question... Basically, I've downloaded some "Desktop Blog Applications" which is a desktop applications that lets you post to your blog. You get the usual headline/text form and you can add images and stuff. When using these application, you get to set up your blog settings, your URL, and then tell ...

php time function

what is wrong with this sql query? he is crying on NOW() :( ("INSERT INTO " . PREFIX . "messages (from, to, title, message, date) VALUES (" . $from . ", " . $to . ", " . $subject . ", " . $message . ", NOW())"); ...

Strlen for non english language

Hello, i want to display short description of articles on home page. Descriptions are a mix of Thai and English language. I am using this function for strlen mb_strlen($str, 'UTF-8'); but this is not acurate as some descriptions end up in just one line and some goes upto 3 lines and I want to show descriptions of two lines. If strl...

Foreign characters turn into garbage in mysql

I am in the U.S. I have the following line in my web page: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> And my MYSQL table is MyISAM latin1_swedish_ci But when someone fills out a form with a foreign character it gets stored in MySql as garbage. An example would be an e with accent over it, etc. - something...

Why would a script not like using MySQLi but is fine with MySQL?

I'm having some issues using mysqli to execute a script with SELECT,DELETE,INSERT and UPDATE querys. They work when using norm mysql such as mysql_connect but im getting strange results when using mysqli. It works fine with a lot of the SELECT querys in other scripts but when it comes to some admin stuff it messes up. Its difficult to e...

How can I properly parse a SimpleXML Object in PHP?

I'm using the CloudFusion class to get Amazon.com data and my code is simple: $items = $pas->item_search( "shoes", array( "ResponseGroup" => "Small", "SearchIndex" => "Blended" )); $items = $items->body->Items; echo "<pre>"; print_r( $items ); echo "</pre>"; This returns the following: SimpleXMLElement Object ( [Request...

How do I find my local host and username on mysql?

I need to open my database through PHP but I need to know my username and the name of my localhost, and i don't know them. When i used mysql and did my database it just asked me directly for a password. ...

PHP preg_match help please. Pretty simple

Hi , How do I add into the list of items allowed (gif$|jpg$|png$|jpeg$) into the following code $regexp = "/[0-9a-zA-z\.]/"; if (preg_match($regexp, $imageInput)) also how do I add in an exclude list e.g so stop people unploading .exe files etc. Thanks EDIT I fixed it with the following code any advice on how to make it better ...

How to add a view helper directory (zend framework)

Hi, I begin with ZF (1.9.7), and I want to use View Helpers from a library shared between all my projects. But I can't find how to add it directory to the helpers path. My herpers works fines when I put them in application's helpers path. Here is the error, where I find the path to ZF helpers, and path to the applications ones. objec...

How to get View From child of Zend_Controller_Plugin_Abstract?

Just need to set up navigation per admin module, I know it is strange and not really good practice may be but I need to set it for admin part. thanks ...

php security question

Hi, It has a been a long day but I cannot seem to choose in my own head which is better or if I should use both. Basically what should I use to sanitize user inputted values. Is it either the htmlentities or preg_match function ? I will then if the value goes into a sql query use the mysql_real_escape_string function but only until I...

Using html radio buttons (or alternative) to call a php function without javascript

Is it possible to call a php function when an html radio button is selected? I'm working on building a donate page for a small non-profit school that will have three options: Donate, Pay Tuition, or Make a Monthly Donation. I would like for the choice of the radio button to load the rest of the webpage based on their selection. If poss...

Is there any reason to use XML/XSLT when using a PHP/MySQL App?

I have been making HTML/PHP/MySQL database apps for quite a while now. I have avoided using XML/XSLT in any application since I just pull the data out and format it within my PHP script, and display it. Assuming I am not wanting my data to be portable to other people's applications (via XML), is there any reason to implement an XML/XSL...