php

Loging in to SquirrelMail from a web page login form using PHP

Hello, I am quite new to php and I need to login squirrelmail from a web page form without going to the default SquirrelMail login page. Can you please tell me how to go about this? A very detailled step by step procedure will be appreciated. ...

Multiple <input type="radio" /> with the same name,how to know which is checked from PHP?

... <input type="radio" name="radio" id="radio1" /> <input type="radio" name="radio" id="radio2" /> .. Supposed it's submited with method="POST". ...

activity in past hour

I am trying to work out if users have had activity in the past hour. The following is my code, but it always returns yes, no matter what: $houraway = (int)mktime() + (60 * 60); $now = mktime(); while($user = mysql_fetch_array($qusers)) { echo $user['Name']." - "; $datetime = explode(" ", $user['Custom6']); $date = $dateti...

Problem with using require inside a function and variable scope

I'm using an MVC setup and I'm trying to inject javascript into my views (.php), yet allow the javascript access to all the variables that the view has access to. My end goal is to be able to access PHP variables from my javascript (for example so I could alert() a product's name). Here's my application flow: start output buffer call ...

Reading php scripts from php file

I have a file named "connection.php". I want to read the contents of this file to a string. i use fopen, and read functions for reading. But when i am reding i just got only last 2-3 lines on that file. That means no php scripts canot read like echo , fuctions etc... How can i read the whole contents on that file?? ...

alternatives to php in_array for large arrays for avoiding duplicates entries

I need to generate a large list of random numbers from 600k to 2000k, but the list can not have duplicates. My current 'implementation' looks like this: <?php header('Content-type: text/plain'); $startTime = microtime(true); $used = array(); for ($i=0; $i < 600000; ) { $random = mt_rand(); //if (!in_arr...

PHP Access to Dictionary Audio files

I am looking for an api file to a dictionary that I can access audio files that are used as well as definitions. So far there have only been references to some sites that provide help in the definition area. does anyone know of any? ...

In what scenarios is it better to use tables for user sessions rather than native sessions?

That's about all that I need to ask I am dealing with a site right now and I can't see a really significant difference in storing my sessions in a database table over and not doing so. ...

How to get the currently logged in user's role in wordpress?

How to get the currently logged in user's role in wordpress? ...

Looking for a PHP Indentation tool?

Is there something like the "phpCodeBeautifier" from waterproof that is open source? ...

How to set and enable new php content by date in php?

I would like to set 5 new content items for monday through friday, but don't want to have to enable them each day. Would it be best to set a timestamp in a mysql field, then something like this. Set up a crontab with php that runs if timestamp is equal to today set "on" to 1. What date/time format would be best, also if I put dates 0...

PHP trim row results?

Hello I'm getting results in format location1 2 4 location2 3 2 location3 0 0 location1 1 0 How can I trim results so that row returning 0 and 0 is not displayed ? thank you ................. Here is Mysql query, I don't know how to trim it from MySQL so I thought using PHP .. SELECT hotelas.name, hotelas.address, hotelas.cit...

how to get a data from a DB using MYSQL and store it in javascript Array.

Hi all, Is there any possible way to get a data from a DB using MYSQL and store it in javascript Array. Thanks in Advance ...

How do I pass cookies on a CURL redirect?

Hi, imagine the following scenario: I open a CURL connection and pass some XML-Logindata via POST. The server answers with an 302 redirect, where the session cookies are set and redirects me to a following "welcome"-page. If I enable FOLLOWLOCATION the cookies set on the redirection-page get lost and the welcome-page fails with a "sessi...

How do I check if the same tag was already in database with PHP and Mysql?

I want this script to check to see if the same word has been entered if so it should add it to the count not add a duplicate tag. And if the tag entered is a new tag then let it add it to the database. Can some one help me fix this? $tag = mysql_real_escape_string($_POST['tag']); $query = "INSERT INTO tags (tag, count) VALUES ('$tag',...

Include view file within same namespace in PHP 5.3.0

Hi, I started developing sort of a mvc framweork on PHP5.3.0 for the static keyword, but since I'm here I said I should take advantage of the namespaces as well. So I have something like this for the view: namespace view { function load($filepath) { include($filepath); } function helper() { echo 'lo...

How do I stop a PHP form from adding blank info to the MYSQL database when page is refreshed ?

If needed I will place the code I just wanted to know what code will I need and where do I place it to stop a form that has empty fields from being entered into the database. A code snippet would be appreciated. This question may be too vague let me know. I'm using PHP and mysql. ...

Array, how to display the "changing values" only

Let's say I have an array with dates and seasons, there is one entry for each day. I would like to print the array row only when the season value is changing. the array look like that: 2009-10-28 00:00:00 (good season) 2009-10-29 00:00:00 (good season) 2009-10-30 00:00:00 (good season) 2009-10-31 00:00:00 (good season) 2009-11...

How to use Constant Contact API?

Hi friends, I want to use API of the constant contact and want to insert user email using PHP while user register to the site. please reply if any help. Thanks in advance. ...

How to reverse a string with PHP?

$s = '1000'; after process,should be '0001' ...