PHP - Captcha Returns Undefined Call To Function Error
can anyone see the problem here
i am running php 5.3 on my server and GD seems to be enabled. and my host said it was probably something to do with the captcha files or script. <?php session_start(); /* * File: CaptchaSecurityImages.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 03/08/06 * Updated: 2007-08-12 by Jenny Ferenc (minor visual changes only) * Requirements: PHP 4/5 with GD and FreeType libraries * Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class CaptchaSecurityImages { var $font = 'VeraSe.ttf'; function generateCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } function CaptchaSecurityImages($width=130, $height=40, $characters=6) { $code = $this->generateCode($characters); // font size will be 60% of the image height $font_size = $height * 0.6; $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream'); // set the colours $background_color = imagecolorallocate($image, 255, 255, 255); $text_color = imagecolorallocate($image, 20, 40, 100); $noise_color = imagecolorallocate($image, 100, 120, 180); // generate random dots in background for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } // generate random lines in background for( $i=0; $i<($width*$height)/150; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } // create textbox and add text $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); // output captcha image to browser header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; } } $captcha = new CaptchaSecurityImages(); ?> this seems to be the problem line he Code: [Select] $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); [\code] Similar TutorialsSomething strange is happning, line producing the error: if( ($this->subject == "") || ($this->message == "") ){ Any ideas guys? thanks lots!! After I did enable the following error reporting: Code: [Select] Default Value: E_ALL & ~E_NOTICE I am getting the error message described in the title of this thread. I do have the php_mysqli.dll extension enabled as well - AND the function used to work as is, before I changed the error reporting, thus the function actually should be defined, what could be another reason, that PHP thinks it is not a defined function? MySQL Client Version: 5.1.50-community PHP Version: 5.3.5 Apache Version: 2.2.17 Okay, I am trying to get MySQL to cooperate with PHP. All of my attempts have been unsuccessful. Before you post a reply, please note I have taken these steps before I posted this topic: 1. My libmySQL.dll is in both my php and C:\Windows folder 2a. (Mental note: my installation directory is C:\Program Files\Apache 2.2\php\ext) 2b. The extension_dir in my php.ini file is as follows: Code: [Select] extension_dir = "C:\Program Files\Apache 2.2\php\ext"3. The php.ini file is also in the C:\Windows folder. 4. The extensions that are enabled for php are as follows: Code: [Select] [PHP_MYSQL] extension=php_mysql.dll [PHP_MYSQLI] extension=php_mysqli.dll [PHP_PDO_MYSQL] extension=php_pdo_mysql.dll5. Any section referencing to MySQL in my php info is not showing up. 6. I have tried replacing my php_mysql.dll, didn't work either. Okay, so when I try to install my forums for my website, it returns with this error: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache 2.2\htdocs\forum\upload\includes\class_core.php on line 312 Please notify me of anything that has or will work(ed). when I try to upload the image on submit, I get there following error: Fatal error: Call to undefined function file_extension() in editlogo.php on line 41 Line 41 is the very last line of the code. Code: [Select] // get form data, making sure it is valid $img_name = $_FILES['myimage']['name']; $tmp_name = $_FILES['myimage']['tmp_name']; $img_size = $_FILES['myimage']['size']; if ($img_name) { if ($img_size>2097152) { die('Max image size is 2mb!'); } else { $file_ext = file_extension($img_name); I am using tidy_repair_string() function as part of a string filter, the except is below.
/* Tell Tidy to produce XHTML */ $xhtml = tidy_repair_string($html, array('output-xhtml' => true));I am getting a fatal error thrown up as below. I thought tidy_repair_string() is an inbuilt PHP function or is it not? Fatal error: Call to undefined function tidy_repair_string() in C:\wamp\www\APPLICATION-FOLDER\contituency-manager\filter.php on line 14 I keep getting this error and can not figure out what is wrong: Fatal error: Call to undefined function showcart() in C:\xampp\htdocs\sas\shoppingcart\showcart.php on line 8 I have attached both the showcart.php and the functions.php files any help will be appreciated Thank you John Im taking my on-the-job. Code: [Select] <?php $zip = zip_open("zip.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $fp = fopen("zip/".zip_entry_name($zip_entry), "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp,"$buf"); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); } ?> my supervisor said that i have a library to add.. im searching on it but i cant find anything.. help pls.. i run this on linux. Hello, i use MySQL with PHP. My php version is 5.2.0. After i connect to the db i use mysql_set_charset in order to change the system variables (character_set_client , character_set_results ,character_set_connection). i do: Code: [Select] if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); mysql_set_charset('utf8',$$link); } else { $$link = mysql_connect($server, $username, $password); mysql_set_charset('utf8',$$link); } I take the error: Fatal error: Call to undefined function mysql_set_charset(). In the manual page for mysql_set_character says: 1."(PHP 5 >= 5.2.3)" --> that means that i have an old php version?? 2."Note: This is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended. " What shall i do in order to solve my problem?? thanks, in advance! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=345884.0 Im working with php 5.1.6. With xampp 1.5.14.
Im also working on a stock application. If I want to say add stock product (add_stock.php) this error is generated on screen. It seems to refer to a function in ump.class.php
Here we go,
ump.class.php
<?php /** * GUMP - A fast, extensible PHP input validation class * * @author Sean Nieuwoudt (http://twitter.com/SeanNieuwoudt) * @copyright Copyright (c) 2011 Wixel.net * @link http://github.com/Wixel/GUMP * @version 1.0 */ class GUMP { // Validation rules for execution protected $validation_rules = array(); // Filter rules for execution protected $filter_rules = array(); // Instance attribute containing errors from last run protected $errors = array(); // ** ------------------------- Validation Data ------------------------------- ** // public static $basic_tags = "<br><p><a><strong><b><i><em><img><blockquote><code><dd><dl><hr><h1><h2><h3><h4><h5><h6><label><ul><li><span><sub><sup>"; public static $en_noise_words = "about,after,all,also,an,and,another,any,are,as,at,be,because,been,before, being,between,both,but,by,came,can,come,could,did,do,each,for,from,get, got,has,had,he,have,her,here,him,himself,his,how,if,in,into,is,it,its,it's,like, make,many,me,might,more,most,much,must,my,never,now,of,on,only,or,other, our,out,over,said,same,see,should,since,some,still,such,take,than,that, the,their,them,then,there,these,they,this,those,through,to,too,under,up, very,was,way,we,well,were,what,where,which,while,who,with,would,you,your,a, b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$,1,2,3,4,5,6,7,8,9,0,_"; // ** ------------------------- Validation Helpers ---------------------------- ** // /** * Shorthand method for inline validation * * @param array $data The data to be validated * @param array $validators The GUMP validators * @return mixed True(boolean) or the array of error messages */ public static function is_valid(array $data, array $validators) { $gump = new Gump(); $gump->validation_rules($validators); if($gump->run($data) === false) { return $gump->get_readable_errors(false); } else { return true; } } /** * Magic method to generate the validation error messages * * @return string */ public function __toString() { return $this->get_readable_errors(true); } /** * Perform XSS clean to prevent cross site scripting * * @static * @access public * @param array $data * @return array */ public static function xss_clean(array $data) { foreach($data as $k => $v) { $data[$k] = filter_var($v, FILTER_SANITIZE_STRING); } return $data; } /** * Getter/Setter for the validation rules * * @param array $rules * @return array */ public function validation_rules(array $rules = array()) { if(!empty($rules)) { $this->validation_rules = $rules; } else { return $this->validation_rules; } } /** * Getter/Setter for the filter rules * * @param array $rules * @return array */ public function filter_rules(array $rules = array()) { if(!empty($rules)) { $this->filter_rules = $rules; } else { return $this->filter_rules; } } /** * Run the filtering and validation after each other * * @param array $data * @return array * @return boolean */ public function run(array $data) { $data = $this->filter($data, $this->filter_rules()); $validated = $this->validate( $data, $this->validation_rules() ); if($validated !== true) { return false; } else { return $data; } } /** * Sanitize the input data * * @access public * @param array $data * @return array */ public function sanitize(array $input, $fields = NULL, $utf8_encode = true) { $magic_quotes = (bool)get_magic_quotes_gpc(); if(is_null($fields)) { $fields = array_keys($input); } foreach($fields as $field) { if(!isset($input[$field])) { continue; } else { $value = $input[$field]; if(is_string($value)) { if($magic_quotes === TRUE) { $value = stripslashes($value); } if(strpos($value, "\r") !== FALSE) { $value = trim($value); } if(function_exists('iconv') && function_exists('mb_detect_encoding') && $utf8_encode) { $current_encoding = mb_detect_encoding($value); if($current_encoding != 'UTF-8' && $current_encoding != 'UTF-16') { $value = iconv($current_encoding, 'UTF-8', $value); } } $value = filter_var($value, FILTER_SANITIZE_STRING); } $input[$field] = $value; } } return $input; } /** * Return the error array from the last validation run * * @return array */ public function errors() { return $this->errors; } /** * Perform data validation against the provided ruleset * * @access public * @param mixed $input * @param array $ruleset * @return mixed */ public function validate(array $input, array $ruleset) { $this->errors = array(); foreach($ruleset as $field => $rules) { #if(!array_key_exists($field, $input)) #{ # continue; #} $rules = explode('|', $rules); foreach($rules as $rule) { $method = NULL; $param = NULL; if(strstr($rule, ',') !== FALSE) // has params { $rule = explode(',', $rule); $method = 'validate_'.$rule[0]; $param = $rule[1]; } else { $method = 'validate_'.$rule; } if(is_callable(array($this, $method))) { $result = $this->$method($field, $input, $param); if(is_array($result)) // Validation Failed { $this->errors[] = $result; } } else { throw new Exception("Validator method '$method' does not exist."); } } } return (count($this->errors) > 0)? $this->errors : TRUE; } /** * Process the validation errors and return human readable error messages * * @param bool $convert_to_string = false * @param string $field_class * @param string $error_class * @return array * @return string */ public function get_readable_errors($convert_to_string = false, $field_class="field", $error_class="error-message") { if(empty($this->errors)) { return ($convert_to_string)? null : array(); } $resp = array(); foreach($this->errors as $e) { $field = ucwords(str_replace(array('_','-'), chr(32), $e['field'])); $param = $e['param']; switch($e['rule']) { case 'validate_required': $resp[] = "The <span class=\"$field_class\">$field</span> field is required"; break; case 'validate_valid_email': $resp[] = "The <span class=\"$field_class\">$field</span> field is required to be a valid email address"; break; case 'validate_max_len': if($param == 1) { $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be shorter than $param character"; } else { $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be shorter than $param characters"; } break; case 'validate_min_len': if($param == 1) { $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be longer than $param character"; } else { $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be longer than $param characters"; } break; case 'validate_exact_len': if($param == 1) { $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be exactly $param character in length"; } else { $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be exactly $param characters in length"; } break; case 'validate_alpha': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain alpha characters(a-z)"; break; case 'validate_alpha_numeric': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain alpha-numeric characters"; break; case 'validate_alpha_dash': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain alpha characters & dashes"; break; case 'validate_numeric': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain numeric characters"; break; case 'validate_integer': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain a numeric value"; break; case 'validate_boolean': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain a true or false value"; break; case 'validate_float': $resp[] = "The <span class=\"$field_class\">$field</span> field may only contain a float value"; break; case 'validate_valid_url': $resp[] = "The <span class=\"$field_class\">$field</span> field is required to be a valid URL"; break; case 'validate_url_exists': $resp[] = "The <span class=\"$field_class\">$field</span> URL does not exist"; break; case 'validate_valid_ip': $resp[] = "The <span class=\"$field_class\">$field</span> field needs to contain a valid IP address"; break; case 'validate_valid_cc': $resp[] = "The <span class=\"$field_class\">$field</span> field needs to contain a valid credit card number"; break; case 'validate_valid_name': $resp[] = "The <span class=\"$field_class\">$field</span> field needs to contain a valid human name"; break; case 'validate_contains': $resp[] = "The <span class=\"$field_class\">$field</span> field needs contain one of these values: ".implode(', ', $param); break; case 'validate_street_address': $resp[] = "The <span class=\"$field_class\">$field</span> field needs to be a valid street address"; break; } } if(!$convert_to_string) { return $resp; } else { $buffer = ''; foreach($resp as $s) { $buffer .= "<span class=\"$error_class\">$s</span>"; } return $buffer; } } /** * Filter the input data according to the specified filter set * * @access public * @param mixed $input * @param array $filterset * @return mixed */ public function filter(array $input, array $filterset) { foreach($filterset as $field => $filters) { if(!array_key_exists($field, $input)) { continue; } $filters = explode('|', $filters); foreach($filters as $filter) { $params = NULL; if(strstr($filter, ',') !== FALSE) { $filter = explode(',', $filter); $params = array_slice($filter, 1, count($filter) - 1); $filter = $filter[0]; } if(is_callable(array($this, 'filter_'.$filter))) { $method = 'filter_'.$filter; $input[$field] = $this->$method($input[$field], $params); } else if(function_exists($filter)) { $input[$field] = $filter($input[$field]); } else { throw new Exception("Filter method '$filter' does not exist."); } } } return $input; } // ** ------------------------- Filters --------------------------------------- ** // /** * Replace noise words in a string (http://tax.cchgroup.com/help/Avoiding_noise_words_in_your_search.htm) * * Usage: '<index>' => 'noise_words' * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_noise_words($value, $params = NULL) { $value = preg_replace('/\s\s+/u', chr(32),$value); $value = " $value "; $words = explode(',', self::$en_noise_words); foreach($words as $word) { $word = trim($word); $word = " $word "; // Normalize if(stripos($value, $word) !== FALSE) { $value = str_ireplace($word, chr(32), $value); } } return trim($value); } /** * Remove all known punctuation from a string * * Usage: '<index>' => 'rmpunctuataion' * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_rmpunctuation($value, $params = NULL) { return preg_replace("/(?![.=$'€%-])\p{P}/u", '', $value); } /** * Translate an input string to a desired language [DEPRECIATED] * * Any ISO 639-1 2 character language code may be used * * See: http://www.science.co.il/language/Codes.asp?s=code2 * * @access protected * @param string $value * @param array $params * @return string */ /* protected function filter_translate($value, $params = NULL) { $input_lang = 'en'; $output_lang = 'en'; if(is_null($params)) { return $value; } switch(count($params)) { case 1: $input_lang = $params[0]; break; case 2: $input_lang = $params[0]; $output_lang = $params[1]; break; } $text = urlencode($value); $translation = file_get_contents( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q={$text}&langpair={$input_lang}|{$output_lang}" ); $json = json_decode($translation, true); if($json['responseStatus'] != 200) { return $value; } else { return $json['responseData']['translatedText']; } } */ /** * Sanitize the string by removing any script tags * * Usage: '<index>' => 'sanitize_string' * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_sanitize_string($value, $params = NULL) { return filter_var($value, FILTER_SANITIZE_STRING); } /** * Sanitize the string by urlencoding characters * * Usage: '<index>' => 'urlencode' * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_urlencode($value, $params = NULL) { return filter_var($value, FILTER_SANITIZE_ENCODED); } /** * Sanitize the string by converting HTML characters to their HTML entities * * Usage: '<index>' => 'htmlencode' * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_htmlencode($value, $params = NULL) { return filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS); } /** * Sanitize the string by removing illegal characters from emails * * Usage: '<index>' => 'sanitize_email' * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_sanitize_email($value, $params = NULL) { return filter_var($value, FILTER_SANITIZE_EMAIL); } /** * Sanitize the string by removing illegal characters from numbers * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_sanitize_numbers($value, $params = NULL) { return filter_var($value, FILTER_SANITIZE_NUMBER_INT); } /** * Filter out all HTML tags except the defined basic tags * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_basic_tags($value, $params = NULL) { return strip_tags($value, self::$basic_tags); } /** * Filter out all SQL Valnurablities * * @access protected * @param string $value * @param array $params * @return string */ protected function filter_mysql_escape($value, $params = NULL) { return mysql_real_escape_string($value); } // ** ------------------------- Validators ------------------------------------ ** // /** * Verify that a value is contained within the pre-defined value set * * Usage: '<index>' => 'contains,value value value' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_contains($field, $input, $param = NULL) { $param = trim(strtolower($param)); $value = trim(strtolower($input[$field])); if (preg_match_all('#\'(.+?)\'#', $param, $matches, PREG_PATTERN_ORDER)) { $param = $matches[1]; } else { $param = explode(chr(32), $param); } if(in_array($value, $param)) { // valid, return nothing return; } else { return array( 'field' => $field, 'value' => $value, 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Check if the specified key is present and not empty * * Usage: '<index>' => 'required' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_required($field, $input, $param = NULL) { if(isset($input[$field]) && trim($input[$field]) != '') { return; } else { return array( 'field' => $field, 'value' => NULL, 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided email is valid * * Usage: '<index>' => 'valid_email' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_email($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_EMAIL)) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value length is less or equal to a specific value * * Usage: '<index>' => 'max_len,240' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_max_len($field, $input, $param = NULL) { if(!isset($input[$field])) { return; } if(function_exists('mb_strlen')) { if(mb_strlen($input[$field]) <= (int)$param) { return; } } else { if(strlen($input[$field]) <= (int)$param) { return; } } return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } /** * Determine if the provided value length is more or equal to a specific value * * Usage: '<index>' => 'min_len,4' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_min_len($field, $input, $param = NULL) { if(!isset($input[$field])) { return; } if(function_exists('mb_strlen')) { if(mb_strlen($input[$field]) >= (int)$param) { return; } } else { if(strlen($input[$field]) >= (int)$param) { return; } } return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } /** * Determine if the provided value length matches a specific value * * Usage: '<index>' => 'exact_len,5' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_exact_len($field, $input, $param = NULL) { if(!isset($input[$field])) { return; } if(function_exists('mb_strlen')) { if(mb_strlen($input[$field]) == (int)$param) { return; } } else { if(strlen($input[$field]) == (int)$param) { return; } } return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } /** * Determine if the provided value contains only alpha characters * * Usage: '<index>' => 'alpha' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_alpha($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!preg_match("/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i", $input[$field]) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value contains only alpha-numeric characters * * Usage: '<index>' => 'alpha_numeric' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_alpha_numeric($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!preg_match("/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i", $input[$field]) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value contains only alpha characters with dashed and underscores * * Usage: '<index>' => 'alpha_dash' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_alpha_dash($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!preg_match("/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$/i", $input[$field]) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a valid number or numeric string * * Usage: '<index>' => 'numeric' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_numeric($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!is_numeric($input[$field])) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a valid integer * * Usage: '<index>' => 'integer' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_integer($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_INT)) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a PHP accepted boolean * * Usage: '<index>' => 'boolean' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_boolean($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } $bool = filter_var($input[$field], FILTER_VALIDATE_BOOLEAN); if(!is_bool($bool)) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a valid float * * Usage: '<index>' => 'float' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_float($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_FLOAT)) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a valid URL * * Usage: '<index>' => 'valid_url' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_url($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_URL)) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if a URL exists & is accessible * * Usage: '<index>' => 'url_exists' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_url_exists($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } $url = str_replace( array('http://', 'https://', 'ftp://'), '', strtolower($input[$field]) ); if(function_exists('checkdnsrr')) { if(!checkdnsrr($url)) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } else { if(gethostbyname($url) == $url) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } } /** * Determine if the provided value is a valid IP address * * Usage: '<index>' => 'valid_ip' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_ip($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_IP) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a valid IPv4 address * * Usage: '<index>' => 'valid_ipv4' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_ipv4($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided value is a valid IPv6 address * * Usage: '<index>' => 'valid_ipv6' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_ipv6($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } if(!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the input is a valid credit card number * * See: http://stackoverflow.com/questions/174730/what-is-the-best-way-to-validate-a-credit-card-in-php * Usage: '<index>' => 'valid_cc' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_cc($field, $input, $param = NULL) { if(!isset($input[$field]) || empty($input[$field])) { return; } $number = preg_replace('/\D/', '', $input[$field]); if(function_exists('mb_strlen')) { $number_length = mb_strlen($input[$field]); } else { $number_length = strlen($input[$field]); } $parity = $number_length % 2; $total = 0; for($i = 0; $i < $number_length; $i++) { $digit = $number[$i]; if ($i % 2 == $parity) { $digit *= 2; if ($digit > 9) { $digit -= 9; } } $total += $digit; } if($total % 10 == 0) { return; // Valid } else { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the input is a valid human name [Credits to http://github.com/ben-s] * * See: https://github.com/Wixel/GUMP/issues/5 * Usage: '<index>' => 'valid_name' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_valid_name($field, $input, $param = NULL) { if(!isset($input[$field])|| empty($input[$field])) { return; } if(!preg_match("/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñðòóôõöùúûüýÿ '-])+$/i", $input[$field]) !== FALSE) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } /** * Determine if the provided input is likely to be a street address using weak detection * * Usage: '<index>' => 'street_address' * * @access protected * @param string $field * @param array $input * @return mixed */ protected function validate_street_address($field, $input, $param = NULL) { if(!isset($input[$field])|| empty($input[$field])) { return; } // Theory: 1 number, 1 or more spaces, 1 or more words $hasLetter = preg_match('/[a-zA-Z]/', $input[$field]); $hasDigit = preg_match('/\d/' , $input[$field]); $hasSpace = preg_match('/\s/' , $input[$field]); $passes = $hasLetter && $hasDigit && $hasSpace; if(!$passes) { return array( 'field' => $field, 'value' => $input[$field], 'rule' => __FUNCTION__, 'param' => $param ); } } } // EOCHere is add_stock.php <?php include_once("init.php"); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>POSNIC - Add Stock Category</title> <!-- Stylesheets --> <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet'> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="js/date_pic/date_input.css"> <link rel="stylesheet" href="lib/auto/css/jquery.autocomplete.css"> <!-- Optimize for mobile devices --> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <!-- jQuery & JS files --> <?php include_once("tpl/common_js.php"); ?> <script src="js/script.js"></script> <script src="js/date_pic/jquery.date_input.js"></script> <script src="lib/auto/js/jquery.autocomplete.js "></script> <script> /*$.validator.setDefaults({ submitHandler: function() { alert("submitted!"); } });*/ $(document).ready(function() { $("#supplier").autocomplete("supplier1.php", { width: 160, autoFill: true, selectFirst: true }); $("#category").autocomplete("category.php", { width: 160, autoFill: true, selectFirst: true }); // validate signup form on keyup and submit $("#form1").validate({ rules: { name: { required: true, minlength: 3, maxlength: 200 }, stockid: { required: true, minlength: 3, maxlength: 200 }, cost: { required: true, }, sell: { required: true, } }, messages: { name: { required: "Please Enter Stock Name", minlength: "Category Name must consist of at least 3 characters" }, stockid: { required: "Please Enter Stock ID", minlength: "Category Name must consist of at least 3 characters" }, sell: { required: "Please Enter Selling Price", minlength: "Category Name must consist of at least 3 characters" }, cost: { required: "Please Enter Cost Price", minlength: "Category Name must consist of at least 3 characters" } } }); }); function numbersonly(e){ var unicode=e.charCode? e.charCode : e.keyCode if (unicode!=8 && unicode!=46 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=9){ //if the key isn't the backspace key (which we should allow) if (unicode<48||unicode>57) return false } } </script> </script> </head> <body> <!-- TOP BAR --> <?php include_once("tpl/top_bar.php"); ?> <!-- end top-bar --> <!-- HEADER --> <div id="header-with-tabs"> <div class="page-full-width cf"> <ul id="tabs" class="fl"> <li><a href="dashboard.php" class="dashboard-tab">Dashboard</a></li> <li><a href="view_sales.php" class="sales-tab">Sales</a></li> <li><a href="view_customers.php" class=" customers-tab">Customers</a></li> <li><a href="view_purchase.php" class="purchase-tab">Purchase</a></li> <li><a href="view_supplier.php" class=" supplier-tab">Supplier</a></li> <li><a href="view_product.php" class="active-tab stock-tab">Stocks / Products</a></li> <li><a href="view_payments.php" class="payment-tab">Payments / Outstandings</a></li> <li><a href="view_report.php" class="report-tab">Reports</a></li> </ul> <!-- end tabs --> <!-- Change this image to your own company's logo --> <!-- The logo will automatically be resized to 30px height. --> <a href="#" id="company-branding-small" class="fr"><img src="<?php if(isset($_SESSION['logo'])) { echo "upload/".$_SESSION['logo'];}else{ echo "upload/posnic.png"; } ?>" alt="Point of Sale" /></a> </div> <!-- end full-width --> </div> <!-- end header --> <!-- MAIN CONTENT --> <div id="content"> <div class="page-full-width cf"> <div class="side-menu fl"> <h3>Stock Management</h3> <ul> <li><a href="add_stock.php">Add Stock/Product</a></li> <li><a href="view_product.php">View Stock/Product</a></li> <li><a href="add_category.php">Add Stock Category</a></li> <li><a href="view_category.php">view Stock Category</a></li> <li><a href="view_stock_availability.php">view Stock Available</a></li> </ul> </div> <!-- end side-menu --> <div class="side-content fr"> <div class="content-module"> <div class="content-module-heading cf"> <h3 class="fl">Add Stock </h3> <span class="fr expand-collapse-text">Click to collapse</span> <div style="margin-top: 15px;margin-left: 150px"></div> <span class="fr expand-collapse-text initial-expand">Click to expand</span> </div> <!-- end content-module-heading --> <div class="content-module-main cf"> <?php //Gump is libarary for Validatoin if(isset($_POST['name'])){ $_POST = $gump->sanitize($_POST); $gump->validation_rules(array( 'name' => 'required|max_len,100|min_len,3', 'stockid' => 'required|max_len,200', 'sell' => 'required|max_len,200', 'cost' => 'required|max_len,200', 'supplier' => 'max_len,200', 'category' => 'max_len,200' )); $gump->filter_rules(array( 'name' => 'trim|sanitize_string|mysql_escape', 'stockid' => 'trim|sanitize_string|mysql_escape', 'sell' => 'trim|sanitize_string|mysql_escape', 'cost' => 'trim|sanitize_string|mysql_escape', 'category' => 'trim|sanitize_string|mysql_escape', 'supplier' => 'trim|sanitize_string|mysql_escape' )); $validated_data = $gump->run($_POST); $name = ""; $stockid = ""; $sell = ""; $cost = ""; $supplier = ""; $category = ""; if($validated_data === false) { echo $gump->get_readable_errors(true); } else { $name=mysql_real_escape_string($_POST['name']); $stockid=mysql_real_escape_string($_POST['stockid']); $sell=mysql_real_escape_string($_POST['sell']); $cost=mysql_real_escape_string($_POST['cost']); $supplier=mysql_real_escape_string($_POST['supplier']); $category=mysql_real_escape_string($_POST['category']); $count = $db->countOf("stock_details", "stock_name ='$name'"); if($count>1) { $data='Dublicat Entry. Please Verify'; $msg='<p style=color:red;font-family:gfont-family:Georgia, Times New Roman, Times, serif>'.$data.'</p>';// ?> <script src="dist/js/jquery.ui.draggable.js"></script> <script src="dist/js/jquery.alerts.js"></script> <script src="dist/js/jquery.js"></script> <link rel="stylesheet" href="dist/js/jquery.alerts.css" > <script type="text/javascript"> jAlert('<?php echo $msg; ?>', 'POSNIC'); </script> <?php } else { if($db->query("insert into stock_details(stock_id,stock_name,stock_quatity,supplier_id,company_price,selling_price,category) values('$stockid','$name',0,'$supplier',$cost,$sell,'$category')")) { $db->query("insert into stock_avail(name,quantity) values('$name',0)"); $msg=" $name Stock Details Added" ; header("Location: add_stock.php?msg=$msg"); }else echo "<br><font color=red size=+1 >Problem in Adding !</font>" ; } } } if(isset($_GET['msg'])){ $data=$_GET['msg']; $msg='<p style=color:#153450;font-family:gfont-family:Georgia, Times New Roman, Times, serif>'.$data.'</p>';// ?> <script src="dist/js/jquery.ui.draggable.js"></script> <script src="dist/js/jquery.alerts.js"></script> <script src="dist/js/jquery.js"></script> <link rel="stylesheet" href="dist/js/jquery.alerts.css" > <script type="text/javascript"> jAlert('<?php echo $msg; ?>', 'POSNIC'); </script> <?php } ?> <form name="form1" method="post" id="form1" action=""> <table class="form" border="0" cellspacing="0" cellpadding="0"> <tr> <?php $max = $db->maxOfAll("id", "stock_details"); $max=$max+1; $autoid="SD".$max.""; ?> <td><span class="man">*</span>Stock ID:</td> <td><input name="stockid" type="text" id="stockid" readonly maxlength="200" class="round default-width-input" value="<?php echo $autoid; ?>" /></td> <td><span class="man">*</span>Name:</td> <td><input name="name"placeholder="ENTER CATEGORY NAME" type="text" id="name" maxlength="200" class="round default-width-input" value="<?php echo $name; ?>" /></td> </tr> <tr> <td><span class="man">*</span>Cost:</td> <td><input name="cost" placeholder="ENTER COST PRICE" type="text" id="cost" maxlength="200" class="round default-width-input" onkeypress="return numbersonly(event)" value="<?php echo $cost; ?>" /></td> <td><span class="man">*</span>Sell:</td> <td><input name="sell" placeholder="ENTER SELLING PRICE" type="text" id="sell" maxlength="200" class="round default-width-input" onkeypress="return numbersonly(event)" value="<?php echo $sell; ?>" /></td> </tr> <tr> <td>Supplier:</td> <td><input name="supplier" placeholder="ENTER SUPPLIER NAME" type="text" id="supplier" maxlength="200" class="round default-width-input" value="<?php echo $supplier; ?>" /></td> <td>Category:</td> <td><input name="category" placeholder="ENTER CATEGORY NAME" type="text" id="category" maxlength="200" class="round default-width-input" value="<?php echo $category; ?>" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <input class="button round blue image-right ic-add text-upper" type="submit" name="Submit" value="Add"> (Control + S) <td align="right"><input class="button round red text-upper" type="reset" name="Reset" value="Reset"> </td> </tr> </table> </form> </div> <!-- end content-module-main --> </div> <!-- end content-module --> </div> <!-- end full-width --> </div> <!-- end content --> <!-- FOOTER --> <div id="footer"> <p>Any Queries email to <a href="mailto:sridhar.posnic@gmail.com?subject=Stock%20Management%20System">sridhar.posnic@gmail.com</a>.</p> </div> <!-- end footer --> </body> </html>now who can tell me what is wrong with the function filter_var() method on line 186 in ump.class.php? $query = "SELECT * FROM School_Registrations WHERE School_Name= '$_POST[SchoolName]' "; $result2 = mysql_query($query); if (mysql_numrows($result2) > 0) { while($row = mysql_fetch_array($result2)) { echo" <h2>ERROR</h2> ...rest of the error code... ";} } else { mysql_query("INSERT INTO ``.`` (...all the variables...);") or die(mysql_error( 'Location: http://www...php' )); echo " ...success code... $url = 'http://www.mypage.com/page.php?'; $url .= 'email='.urlencode($_POST['email']); $result = getPage('', $url, '', 15); function getPage($proxy, $url, $header, $timeout) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_REFERER, 'http://mypage.org'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8'); $result['EXE'] = curl_exec($ch); $result['INF'] = curl_getinfo($ch); $result['ERR'] = curl_error($ch); curl_close($ch); return $result; } } ?> Ok, so this code verifies what the name entered in the forms is not already in database. If it is it gives you the ...error code... and nothing else. If it does not it gives you ...success code... and it creates new table record, and it sends out email address entered to designated page. Bu I keep getting: Fatal error: Call to undefined function getPage() It still fully works, but no email goes out as defined. I am stuck. Help? Hello I am on to OOP now and I dont know how to write the syntax to print the results I want The scenario is I have the abstract class, its subclass and then the object that calls the subclass, all in different files. So: part of the subclass reads: Code: [Select] function __construct($v1, $v2, $v3) { $this->speed[] = $v1; // I dont like this either, it is not elegant. I tried to put an array as argument of the constructor and send the parameters $this->speed[] = $v2; // from the object being created, but it did not work, so I leave it like this for now, but I would have preferred to put that $this->speed[] = $v3; // array and then populate it by some looping. } // METHOD TO REPORT TABLE OF ACCELERATION public function acceleration() { return $this->acceleration1 = ($this->speed[1] - $this->speed[0])/5; // I actually need to return the other two speed differences from the other stages, but as you know, once the first return acts, it exits the function // so sure this "return" has to be abandoned and the results of the function have to be printed otherwise. That is the question. } =================================== And now from the Object file I am trying to call the function, but of course, I only get one value, even if I write 3 times return Code: [Select] $objeto = new Motorbike($v1, $v2, $v3); echo '<p>The speeds are ' . $objeto->acceleration() . '</p>'; // Yes, this call works, of course, but that is about it. I cant print any other result. Thanks a lot Code: [Select] <html> <center> <form method="post" action=""> <b>Email</b><br><input type="text" name="email"/><br> <b>Password</b><br><input type="password" name="password"/><br> <input type="submit" name="submit" value="Login"/><br> </form> <?php if(isset($_POST['submit'])){ echo echo_post($_POST['email']); function echo_post($postvar){ return $postvar; } } ?> </center> </html> the filename is index.php How come I get the undefined function echo_post on line 14? I know it is probably something simple but I am kind of new to this, if you could help me out that would be great This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 Good day! I change my database from sql yog to SQL Server 2005 Express so in php the connection is different, so now I am new in SQL Server 2005 Express. i edit my login page and I encountered error: Fatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\web_intranet\index.php on line 14 here is my code: <?php session_start(); session_regenerate_id(); if($_SESSION['loggedin']){ //the user is already logged in, lets redirect them to the other page header("Location:company.php"); } //require_once 'conn.php'; $server = "PDOMAIN\MSFW"; $db_name="dspi"; mssql_connect($server) or die("Cannot connect to server"); mssql_select_db("$db_name")or die("Cannot select DB"); $department = $_POST['department']; $username = $_POST['username']; $sql=mssql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mssql_min_error_severity()); $ct = mssql_num_rows($sql); if($ct == 1) { // im guessing this means that the user is valid. $_SESSION['loggedin'] = true; // now that the user is valid we change the session value. $row = mssql_fetch_assoc($sql); //$_SESSION['username'] = $row['Username'] ; //$_SESSION['department'] = $row['Department']; $Departments=array('Accounting', 'Engineering', 'Finishing_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain'); if (in_array($row['Department'], $Departments)){ header ('Location:company.php'); }else{ echo "Incorrect Username or Department"; header ('Location:index.php'); } } ?> //$_SESSION['department'] = $row['Department']; $Departments=array('Accounting', 'Engineering', 'Finishing_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain'); if (in_array($row['Department'], $Departments)){ header ('Location:company.php'); }else{ echo "Incorrect Username or Department"; header ('Location:index.php'); } } ?> i already enable extension mssql in php.ini What's undefined about deposit()? Code: [Select] class BankAccount { private $name; var $balance = 0; private $dep = 0; function __construct() { if (array_key_exists ("deposit" , $_POST)) { $dep = $_POST['deposit']; echo $dep; deposit($dep); } } function deposit($dep) { $balance += $dep; echo $balance; } } Currently, I am reading a book called PHP Web 2.0 Mashups and I have stumbled across an error on the second chapter which deals with XML-RPC protocol. The book has the following code which it uses to demonstrate the XML-RPC encoding functionality of PHP with the xmlrpc_encode_request function: <?php $singleVar = "Hello!"; $requestMessage = xmlrpc_encode_request('theRemoteCall', $singleVar); echo $requestMessage; ?> However when I load this page up on my local testing platform nothing is displayed. Upon checking the PHP error log I am confronted with this: [24-Jan-2011 07:56:40] PHP Fatal error: Call to undefined function xmlrpc_encode_request() in C:\wamp\www\jquery\collapsible.php on line 79 A couple of other points in relation to this: 1. I have the following lines in my PHP.ini file: Code: [Select] ; Turn off normal error reporting and emit XML-RPC error XML ; http://php.net/xmlrpc-errors ;xmlrpc_errors = 0 ; An XML-RPC faultCode ;xmlrpc_error_number = 0 Does this not mean that xmlrpc functions are all ready installed on my WAMP server? I have download XML-RPC for PHP from http://phpxmlrpc.sourceforge.net/ (3.0.0 beta) and placed the files inside the extracted 'lib' folder into C:/PHP/includes and uncommented the PHP.ini line 'include_path = ".;c:\php\includes"'. However still, after restarting WAMP and refreshing the page it is still issuing a fatal error in PHP error log. Thank you for all your help in advance. Error: call to undefined function mcrypt_module_open() I have copied this code form net. And i think so that mcrypt_module_open() would be a built in function. But I think it is not so. How can i define this function. OR any other way to solve this problem?? Code: [Select] $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $iv_size = mcrypt_enc_get_iv_size($cipher); printf("iv_size = %d\n",$iv_size); $key256 = '12345678901234561234567890123456'; $key128 = '1234567890123456'; $iv = '1234567890123456'; printf("iv: %s\n",bin2hex($iv)); printf("key256: %s\n",bin2hex($key256)); printf("key128: %s\n",bin2hex($key128)); $cleartext = 'The quick brown fox jumped over the lazy dog'; printf("plainText: %s\n\n",$cleartext); if (mcrypt_generic_init($cipher, $key256, $iv) != -1) { // PHP pads with NULL bytes if $cleartext is not a multiple of the block size.. $cipherText = mcrypt_generic($cipher,$cleartext ); mcrypt_generic_deinit($cipher); // Display the result in hex. printf("256-bit encrypted result:\n%s\n\n",bin2hex($cipherText)); } if (mcrypt_generic_init($cipher, $key128, $iv) != -1) { // PHP pads with NULL bytes if $cleartext is not a multiple of the block size.. $cipherText = mcrypt_generic($cipher,$cleartext ); mcrypt_generic_deinit($cipher); // Display the result in hex. printf("128-bit encrypted result:\n%s\n\n",bin2hex($cipherText)); }Thanks In advance Hi all I have been trying to do a query but I get Call to undefined function mysql_connect() What other way can I perform a query? Or do I need to get something enabled? Thank in advance Dave |