php

How to detect duplicate values in PHP array?

Hi! I am working with a one dimensional array in PHP. I would like to detect the presence of duplicate values, then count the number of duplicate values and out put the results. For example, given the following array: $array = array('apple', 'orange', 'pear', 'banana', 'apple', 'pear', 'kiwi', 'kiwi', 'kiwi'); I would like to pr...

.htaccess with dynamic php - subfolder problems

Hi, Necessary Knowledge My .htaccess file redirects like this: domain.com/about to domain.com/index.php?page=about RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L] The "page" variable is used in a php include: <?php include_once($_SERVER['DOCUMENT_ROOT']."/contents/".$page.".html"); ?> The "contents" folder simply contains .html...

how to handle 1 value returned from sql in php

$query = "SELECT val FROM table WHERE id = 1"; mysql_query($query); This returns a single peice of data from the database. all the ways I know how to deal with this data are mysql_fetch_array() and mysql_fetch_assoc() is there a way to deal with 1 peice of data that doesn't involve pulling it into an array? ...

strip all classes from p tags

Hi everyone, I was just wondering if any one knew a function to remove ALL classes from a string in php.. Basically I only want <p> tags rather than <p class="..."> If that makes sense :) ...

Initialize Global Variables in PHP

Is it good practice to initialize a global variable in PHP? The snippet of code seems to work fine, but is it better to initialize (in a larger project, say for performance sake) the variable outside of a function, like in the second scratch of code? if(isset($_POST["Return"]))Validate(); function Validate(){ (!empty($_POST["From"])...

Remove .php with mod_rewrite

How can I change this url: http://localhost/index.php/Department/2 to this one: http://localhost/index/Department/2 Thanks. ...

Friend Invite Feature for Facebook Applications

How can I add a friend invite feature to my newly created Facebook application? ...

reverse mysql_real_escape_string

I have a peice of data that is large and will probably contain quotes and double quotes. I'm using mysql_real_escape_string() to store it safely. When I pull it out to look at it, all the quotes are escaped. I tried using str_replace to just get rid of all the quotes, but that turns \r\n's into rn. :( How can I reverse it so the data ...

can we avoid browser's "remember password" when a user tries to log in to the system?

Hi I know that this feature is to enhance user experience (by not retyping their details every time) and users can tweak their browser settings, but is it possible to send some "headers" etc (or any method, I mean server side controlling) so that when users try to log into my site they dont get this "Do you want IE/Firefox to remember y...

PHP automatic list creation from a textfile to (X)HTML

Hi all people! I'm creating a CMS as you might already know, and now I have a lil' problem. Lets say: I have a textfile containing this: [b]Some bold text[/b] [i]Italic[/i] - List item 1 - List item 2 - List item 3 # List item 1 # List item 2 # List item 3 And I want to convert it to: <b>Some bold text</b> <i>Italic</i> <ul> <l...

'Memcache' not found in command line PHP script

I have Memcache installed and working for PHP apps run through Apache (v2.2) but when I try to run a .php file in the command-line i get this error: Fatal error: Class 'Memcache' not found in /usr/local/Matters/app/matters-common/connection.php on line 94 Line 94 is: $memcache = new Memcache; Other info: CentOS 5.2 PHP 5.2.5 (cli)...

Advantages Of MySQLi over MySQL

What are the advantages of using MySQLi over MySQL? ...

Zend Gdata - setVisibility for newEventEntry? (specify events for multiple calendars)

Hey everyone, I know that you can use setVisibility('private-abcdefg') for newEventQuery() in order to specify a particular calendar. My question is, can I use the same concept for newEventEntry()? $gdataCal = new Zend_Gdata_Calendar($client); $newEvent = $gdataCal->newEventEntry(); $newEvent->setVisibility('private-**************...

Unbelievable PHP script won't echo out string

Hello all, I have a test.php script which contains this: <?php echo 'test'; ?> When I point to it via my browser, it works and prints out "test" as expected. I have another script which I am trying to test but however, it is ignoring all my echos! I thought I would put an echo right at the top as this will surely work, but when I ge...

Interpret text input as PHP

I want to let users test out a PHP class of mine, that among other things crops and resizes images. I want them to write PHP code in a text field, send the form, and then their code will be run. How can I do this? Or is it other safe ways to let users (anyone) demo a PHP class? ...

How do I make my live jQuery search wait a second before performing the search?

Hi everyone, I've got a search input which sends data from an input to a php file as I type. The php file does a search on my database and shows up a list of search options. You know, the ajax style live searching. My problem is, if you type something really fast, it might just conduct a search off of the first 1 or 2 letters even thou...

How to remove an HTML element using the DOMDocument class

Is there a way off removing an HTML element by using the DOMDocument class? ...

How to load new images, when changed in a web application

How to push new images in a web application, so that the cached is not taken? When I am having a new JS or CSS file, it's easy. Because they are in smarty templates, and I am having a version number in the URL (like a.js?v=9). Now, the problem with images are: - They are referred from the CSS files, and I can not have a version variabl...

encrypting password using php

I need to encrypt the password and store it in the db. i have added a code "$newpass= md5($pass_word);" in php file. but still its not working <?php $hostname = "xxxx"; $username = "xxxx"; $password = "xxxx"; $dbName = "xxxx"; $user_name=''; $pass_word=''; $email=''; $errormsg=''; $subject=''; $message=''; $newpass=''; $conn...

PHP help, I have a "for loop" problems?

Here is my code: $today = date('Y-m-d'); for ($i = 1; $i <= 10; $i ++){ $var_b[$i] = date('Y-m-d', strtotime('-' . $i .' day', strtotime($today))); $var2_b[$i]_name = date('d', strtotime($var_b[$i])); Error message: Parse error: syntax error, unexpected T_STRING in XXX\index.php on line XX EDIT: I put the curly brackets, the erro...