php

Function mcrypt_encrypt() Not working in Wamp(PHP Version 5.2.6)

When I try to use this mcrypt_encrypt() function I am getting following error. Fatal error: Call to undefined function mcrypt_encrypt() in C:\wamp\www\PHP_Kit\FORM_PHP\includes.php on line 307 Help Me. ...

PHP session timeout callback?

I'm running a PHP + APACHE + CENTOS Linux combination. I have implemented a login & logout on the website. My question is, how can I know when the php session has timed-out (User has closed his browser without logging-out)? The reason is, I want perform some cleanups and/or database updates (calling another PHP) when the user has don...

previous - next query in mysql

I have a table in database that is having unique id's. I have a page where one particular id is shown and link is given for next and previous id's. I have to get those prev and next id's by one single mysql query .All i have is that particular id on whose data we are currently working on. id's are not consecutive numbers as sometimes som...

$form->input in cakephp

hi, I'm trying to create a text box using the vales retrieved from the database. But instead of a text box, a select box (drop down box) is created. I do not understand why. I have given the type as text only, then why a select box is being created? echo $form->input($r['Attribute']['label'], array('label' => $r['Attr...

MySQL - insert japanese from PHP - Encoding Troubles! [SOLVED]

Hello! I'm trying to insert some japanese words in a mysql table! If I insert 'こんにちは' using phpMyAdmin, the word is displayed fine from phpMyAdmin. But if I try to insert it through php, as follow: mysql_connect($Host, $User, $Password); mysql_select_db($Database); $qry = "INSERT INTO table VALUES (0 , 'こんにちは')"; echo mysql_query($qr...

AJAX uploading with PHP and Javascript

Hey, I want to dynamically send an upload form to CI via jQuery. The form needs to contain the file to be uploaded and the path to save to. So far my AJAX-call looks like this: file = $('#file').val(); path = active_dir; upload_file( file, path ); function upload_file(file, path) { $.post("/upload_file/", { file: file, path: path ...

Why doesn't this query work?

I have this query: select count(id) AS num,date_id from table where FROM_UNIXTIME(date_id,'%d-%m-%Y')='17-08-2009' order by date_id DESC; This should result in all the id's posted on today's date, but it is giving only one id (the highest one). When I remove count(id) from this query, it runs fine. Why doesn't this count work with...

Forms, Post and submit buttons

I feel a little silly asking this but I wanted everyones opinion on it. I want to submit a page, target itself, on the press of a button but carrying one piece of data with it. Example: Edit | Delete On the click on edit, I want the page to reload with $_POST['example'] === "edit" or something. I don't want to use $_GET and I don't w...

problems getting values from query string

My below function that is copied from another function that works fine. Should get values from the query string and turn them into a date: function updateShift() { echo $name = $_GET['shift_name']; echo $start_date = date('Y-m-d H:i:s', strtotime("{$_GET['start_hours']}:{$_GET['start_minutes']} {$_GET['start_ampm']}")); ...

PHP's file_exists() will not work for me?

For some reason this PHP code below will not work, I can not figure it out. It is very strange, file_exists does not seem to see that the image does exist, I have checked to make sure a good file path is being inserted into the file_exists function and it is still acting up If I change file_exists to !file_exists it will return an ima...

How vulnerable is my code to SQL injection?

Ok I don't want this to be a hacking advice question, so please don't down-vote for that. I work in a web shop and I've found some of our old PHP pages are vulnerable to SQL injection in the username and want to know how bad. We use a PHP string to embed the user input from the POST on the login form. $uname = $_POST['username']; $pas...

PHP OOP lines usage explanation

What is the purpose of these lines: <?php $title=($cfg && is_object($cfg))?$cfg->getTitle():'Apptitle :: My First App'; ?> <?=Format::htmlchars($title)?> Can someone explain the usage here? I see the top line being used as first line in a php file, then the second line being used to populate the title. Why this implementation? Wh...

Google calendar - Showing recurring events like normal events

I'm trying to show a list of the next 20 days' events from a Google calendar account. Infuriatingly recurring events aren't being shown (I assume because their start times are old)... So. Any ideas? require_once dirname(__FILE__).'/../../../Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_HttpCl...

How to remove values from an array in PHP?

Is there a PHP function to remove certain array elements from an array? E.g., I have an array (A) with values and another array (B) from which a need to remove values. Want to remove the values in array A from array B? ...

OSTicket - What's better?

What is the best open source customer support / staff management / job management software out there? We are using OSTicket right now, which has some serious shortcomings. Anyone used anything better? ...

CodeIgniter Routing

I am developing an ecommerce website with CI that has product categories and products. I want to route the URL so that it will go to the products controller, then run the getCategoryByName function for the first segment, then run the getProductByName for the second segment. Here is what I have: URL: products/docupen/rc805 routes.php...

What's the difference between these perl compatible regular expressions?

An answer from another question piqued my curiosity. Consider: $string = "asfasdfasdfasdfasdf[[sometextomatch]]asfkjasdfjaskldfj"; $regex = "/\[\[(.+?)\]\]/"; preg_match($regex, $string, $matches); $regex = "/\[\[(.*)\]\]/"; preg_match($regex, $string, $matches); I asked what the difference between the two regexes is. The aswer I ...

PHP functions help

Hi there! I'm sorry for asking this question, but I'm not good in php (beginner). Could you please explain what $arg means in this piece of code? (it's from one of drupal modules) function node_add_review_load($arg) { global $user; $add_review = FALSE; $current_node = node_load($arg); $type =$current_node->type; $axes_count =...

Zend_Rest_Server doesn't invoke class method

I am trying to Build a basic app, 2 PHP files, one using Zend_Rest_Server, the other - Zend_Rest_Client. Here is server code: class test1 { public function test() { return "mytest"; } } include_once ("common.php"); set_include_path('.' . PATH_SEPARATOR . '..\..\library/' . get_include_path()); require_once 'Zend/Load...

Save an include's output to a string?

Possible Duplicate: Storing echoed strings in a variable in PHP Suppose I have <?php include "print-stuff.php"; ?> print-stuff.php contains PHP/HTML template, which means that when it is included, HTML gets printed. Is there any way to capture that HTML as a string, so that I may save it to use elsewhere? Moving the include s...