php

Session variables

Hy guys. I'm currently working on a project which uses a lot of data stored in session variables. My question is how reliable is this method and if affects the server performance and memory usage. Basicaly, what you would choose between session variables and cookies. ...

PHP: UTF 8 characters encoding

Hey I am scraping a list of RSS feeds by using cURL, and then I am reading and parsing the RSS data with SimpleXML. The sorted data is then inserted into a mySQL database. However, as notice on http://dansays.co.uk/research/MNA/rss.php I am having several issues with characters not displaying correctly. Examples: ‘Guitar Hero: Van ...

Strategy for subdomain applications using PHP

Not quite sure how to phrase this, but will do my best. I have an application (written in PHP) that I want to install somewhere like this: /app/build/1.0/ Now, I want to be able to set up subdomains, something like this: http://sub1.mydomain.com http://sub2.mydomain.com etc .. First, I want to put the least # files as possible in ...

Sorting by Color

I have a long list (1000+) of hex colors broken up in general color categories (Red, Orange, Blue, etc). When I show the list of colors in each category I need to show them in order of shade. i.e. light red first and dark red last. What would the algorithm be to do this? (googling has failed me) ...

Included variables not working in PHP

Alright, so this is something really basic, and I know that when someone tells me the answer I'm going to feel really silly, but I can't for the life of me figure out why the following code isn't working: index.php: <?php include('config.php'); //this works fine. variables in this file are reached correctly - $_MYSQL is defined there ?...

Displaying code as content?

I have a problem as described below Users fill in information in a html textarea. Sometimes they enter code in the textarea. eg. <script src="fancybox/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script> Now I want to display the output in a browser using PHP and the browser does not treat this as text but as code. ...

PHP Regex for human names

I've run into a bit of a problem with a Regex I'm using for humans names. $rexName = '/^[a-z' -]$/i'; Suppose a user with the name Jürgen wishes to register? Or Böb? That's pretty commonplace in Europe. Is there a special notation for this? EDIT:, just threw the Jürgen name against a regex creator, and it splits the word up at the ü ...

Array values disappear in PHP SoapClient call to Cisco phone system.

I am attempting to consume a SOAP service provided by our Cisco phone system (documentation), to get the current status of a given set of phones. I have an array of phone names, which I'm trying to pass to the service, however, the values of the array are being eaten somewhere Array of items like so: $items = array( 0 => "SEP0004F2...

What is the reason for having 2 different "not equal to" operators in PHP?

I just happened to stumbled upon a piece of php code and could see author used <> to do a not equal to comparison: if ($variable <> "") { echo "Hello, I am having some value"; } I have always used !=: if ($variable != "") { echo "Hello, I am having some value"; } Are there any special circumstances, when I should use <> ove...

insert values from checkbox in table using php + mysqli

Hello! I have 3 tables (actors, categories, actor_cats) in my db. I'm using a form to insert new info in the database (mysql). Most of the information goes into the actors table. But in a label "categories", i have a checkbox input type, with 3 fields that i get from the categories table [action (id1), comedy(id2), drama(id3)]. I want ...

PHP namespaces and the implements keyword

use MyNamespace; class NonPersistentStorage implements StorageInterface Both are in MyNamespace. Yet PHP looks for MyNamespace\NonPersistentStorage and StorageInterface (instead of MyNamespace\StorageInterface). Am I missing something? ...

[WordPress] Need help with remove_action()

I'm trying to remove the unsightly embedded <STYLE> tag the built-in Recent Comments widget puts in my <HEAD>, but I can't seem to get the syntax right. It originally calls add_action( 'wp_head', array(&$this, 'recent_comments_style') ); to add it (in wp-includes/default-widgets.php, line 609), and I'm trying to undo it. I think it ...

problem generating a unique file name for uploads php

Im generating a unique filename for uploaded files with the following code $date = date( 'U' ); $user = $_SERVER[REMOTE_ADDR]; $filename = md5($date.$user); The problem is that i want to use this filename again later on in the script, but if the script takes a second to run, im going to get a different filename the second time i try t...

PHP Mail Tutorials

Where I can find tutorials about sending mails in php without my smtp server? ...

How to replace Microsoft-encoded quotes in PHP

I need to replace Microsoft Word version of single and double quotations marks (“ ” ‘ ’) with regular quotes (' and ") due to an encoding issue in my application. I do not need them to be HTML entities and I cannot change my database schema. I have two options: to use either a regular expression or an associated array. Is there a bett...

PHPUnit getMock() with namespace

My quest of starting to use namespaces in PHP keeps continuing. This time PHPUnit gives me problems. My setup() method is like this: $test = new \MyNamespace\NonPersistentStorage(); // works $mock = $this->getMock('\\MyNamespace\\NonPersistentStorage'); // doesn't work The getMock() method only results in PHP looking for a NonPersiste...

Zend: Two Objects, one Row.

I've recently started using Zend Framework (1.8.4), to provide admin tools for viewing the orders of a shopping cart site. What I'd like to do is to efficiently create multiple model (Zend_Db_Table_Row_Abstract) objects from a single database result row. The relationship is simple: an Order has one Customer (foreign key order_custid...

Regular expression negative replace?

I need to get "yomomedia.com" if the HTTP_HOST is [ANY].yomomedia.com except in the cases where it is "dev.yomomedia.com" else it should return dev.yomomedia.com echo preg_replace("/^([EVERYTHING-OTHER-THAN-DEV])\./Ui","",$_SERVER['SERVER_NAME']) Just tried the following with no success: echo preg_replace("/^(?!dev)\./Ui",'','www.yom...

Cut strings short PHP

How would you go about Cutting strings short so it doesnt go to the next line in a div tag For example my message string contained the following: We prefer questions that can be answered, not just discussed. Provide details. Write clearly and simply. If your question is about this website, ask it on meta instead. And i want to pref...

wordpress | carrington theme | sort posts by title within a category

Hi, Can you help. Wordpress can be altered in many ways. in the loop or just before in the functions.php file in the includes/posts.php I want number 3. As the other two do not work in carringtons theme. I have already edited this file and it worked perfectly. Alas it was so long ago that i have forgot how its done. It got removed ...