PHP - Fatal Error: Function Name Must Be A String In W:\www\blog\index.php On Line 14
I am having more trouble with my code, please see the error below when loading my browser:
Here is my blog Fatal error: Function name must be a string in W:\www\blog\index.php on line 14 My code is: Code: [Select] <?php mysql_connect ("localhost", "root", "gwalia"); mysql_select_db("blog"); ?> <html> <head> <title>Show My Blog</title> </head> <body> Here is my blog<hr/> <?php $sql = mysql_query("SELECT * FROM blogdata ORDER BY id DESC"); While($row = mysql_fetch_array($sql)){ $title = $row('title'); $content = $row('content'); $category = $row('category'); ?> <table border='1'> <tr><td><?php echo $title; ?></td><td><?php echo $category; ?></td></tr> <tr><td colspan='2'><?php echo $content; ?></td><td></tr> </table> <?php } ?> </body> </html> Line 14 is '$title = $row('title');'. But i do not know what is wrong with my code, help please? Similar TutorialsHey guys! I know there are a lot of topics about this, but mine is a bit different. I am creating my first contact form with php and I ran across this error after twinking with the php file: Fatal error: Function name must be a string in /www/zymichost.com/m/t/l/mtlproductions/htdocs/Contact2.php on line 11 Here is what my code looks like currently: Code: [Select] <html> <body> <?php include '/www/zymichost.com/m/t/l/mtlproductions/htdocs/header.inc.php';?> <?php include '/www/zymichost.com/m/t/l/mtlproductions/htdocs/menu.inc.php';?> <?php if ($missing || $errors) { ?> <p class="warning">You did not enter the required information. Please try again.</p> <?php }; ?> <?php ($errors); ($missing); if ($isset($_POST['send'])) { $to = 'tate.mikey@gmail.com'; $subject = 'New Feedback Received on MikeyTateLive Productions website'; } $expected = array('name', 'email', 'comments'); $required = array('name', 'comments'); ?> <div id="wrapper"> <div id="maincontent"> <h2>I am here when you need me!</h2> <p>Enter the information below and click send. Hope to hear back from you soon. =)</p> <p>*=required</p> </div> </div> <form id="feedback" method="get" action=""> <p> <label for="name">*Name:</label></br> <input name="name" id="name" type="text" class="formbox"> </p> <p> <label for="email">Email:</label></br> <input name="email" id="email" type="text" class="formbox"> </p> <p> <label for="comments">*Comments:</label></br> <textarea name="comments" id="comments" cols="60" rows="8"></textarea> </p> <p> <input name="send" id="send" type="submit" value="Send" </p> </form> <?php include '/www/zymichost.com/m/t/l/mtlproductions/htdocs/footer.inc.php';?> <?php include '/www/zymichost.com/m/t/l/mtlproductions/htdocs/processmail.inc.php';?> </body> </html> I originally had lines 9 and 10 set up like this except for the php opening and closing tags, lol: Code: [Select] <?php $errors(); $missing(); ?> But as you can see on my full code at lines 9 and 10, I made a minor change to it and now the error comes from line 11 instead of 9 and 10. And now I could use some help with this..... 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?
In PHP Version 8.0 shows error as : In previous versions of PHP it does not show any error. Please resolve the issue. Hello , I have a made a PHP website where users signup and send their Date of Birth and gets an OTP on their email after signup. The OTP is recieved but when we enter the OTP this problem occurs QuoteError! Something went wrong and I am facing this error in the error log QuotePHP Fatal error: Uncaught Error: Object of class DateTime could not be converted to string This is my config.php code <?php session_start(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Confirmation Page - Kanha Stories</title> <style> body { background-color: #330000; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 800 400'%3E%3Cdefs%3E%3CradialGradient id='a' cx='396' cy='281' r='514' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23D18'/%3E%3Cstop offset='1' stop-color='%23330000'/%3E%3C/radialGradient%3E%3ClinearGradient id='b' gradientUnits='userSpaceOnUse' x1='400' y1='148' x2='400' y2='333'%3E%3Cstop offset='0' stop-color='%23FA3' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23FA3' stop-opacity='0.5'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect fill='url(%23a)' width='800' height='400'/%3E%3Cg fill-opacity='0.4'%3E%3Ccircle fill='url(%23b)' cx='267.5' cy='61' r='300'/%3E%3Ccircle fill='url(%23b)' cx='532.5' cy='61' r='300'/%3E%3Ccircle fill='url(%23b)' cx='400' cy='30' r='300'/%3E%3C/g%3E%3C/svg%3E"); background-attachment: fixed; background-size: cover; padding: 20px; width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; color:#ffffff; overflow-x: hidden; } .cont { padding: 20px 40px; position: relative; border-right: 4px solid rgb(184, 182, 182); border-bottom: 4px solid rgb(184, 182, 182); border-radius: 15px; display: flex; flex-direction: column; align-items: center; } #left{ float: left; } #right{ float: right; } input{ margin: 10px 0px; } s{ padding: 5px; } .error{ padding: 5px; color: #ffffff; } .resend{ color: rgb(14, 14, 196); padding: 5px; } .s:hover{ cursor: pointer; background-color:gray; color: rgb(243, 237, 237); border-radius: 5px; } </style> </head> <body> <?php $code=""; $err=""; $error=""; if(($_SERVER["REQUEST_METHOD"]=="GET" && $_SESSION['xyz'] === 'xyz') || isset($_POST['verify']) || isset($_POST['resend'])) { unset($_SESSION["xyz"]); if($_SERVER["REQUEST_METHOD"] ==="POST") { if(isset($_POST['verify'])) { if(empty($_POST['code'])) { $err="Enter the code!"; } else { $code=$_POST['code']; if(password_verify($code,$_SESSION['code'])) { $name=$_SESSION['name']; $email=$_SESSION['email']; $tel=$_SESSION['tel']; $dob=$_SESSION['dob']; $password=$_SESSION['password']; $age_category=$_SESSION['age_category']; require_once('./all_utils/connection.php'); $sql="INSERT INTO identity_table(name,email,password,tel,dob,age_category) VALUES ('$name','$email','".$password."','$tel','$dob','$age_category')"; if(mysqli_query($conn,$sql) === TRUE) { unset($_SESSION["name"]); unset($_SESSION["password"]); unset($_SESSION["dob"]); unset($_SESSION["tel"]); unset($_SESSION["age_category"]); header("location:welcome/welcome.php"); } else { $err="Error! Something went wrong"; } } else { $err="Incorrect code!"; } } } elseif(isset($_POST['resend'])) { require_once('./all_utils/mail.php'); $error="OTP has been sent again!"; } } } else{ header("location:signup.php"); } ?> <div class="cont"> <h2> Email Verification</h2> <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST"> <label for="verification">Enter the 5 digit code</label> <br/> <p> Didn't got the mail? Please check your spam folder </p> <input type="text" name="code" placeholder="Eg. 12345" value="<?php echo $code; ?>"> <br/> <div class="error"><?php echo $err; ?></div> <div class="resend"><?php echo $error;?></div> <input type="submit" name="resend" class="s" id="left" value="Resend OTP"> <input type="submit" name="verify" class="s" id="right" value="Verify"> </form> </div> </body> </html>
This is my signup.php code <?php session_start(); if(!empty($_SESSION['email'])) { require_once('./all_utils/connection.php'); $query="SELECT * FROM identity_table WHERE email='".$_SESSION['email']."'"; $result=mysqli_query($conn,$query); if(mysqli_fetch_assoc($result)) { header("location:welcome/welcome.php"); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>SignUp - Kanha Stories</title> <style> * { margin: 0; padding: 0; } body { width: 100vw; height: 100vh; display: flex; align-items: center; background-color: #ff9d00; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 1600 800'%3E%3Cg stroke='%23000' stroke-width='66.7' stroke-opacity='0' %3E%3Ccircle fill='%23ff9d00' cx='0' cy='0' r='1800'/%3E%3Ccircle fill='%23f27d00' cx='0' cy='0' r='1700'/%3E%3Ccircle fill='%23e55f00' cx='0' cy='0' r='1600'/%3E%3Ccircle fill='%23d84400' cx='0' cy='0' r='1500'/%3E%3Ccircle fill='%23cb2c00' cx='0' cy='0' r='1400'/%3E%3Ccircle fill='%23bf1600' cx='0' cy='0' r='1300'/%3E%3Ccircle fill='%23b20300' cx='0' cy='0' r='1200'/%3E%3Ccircle fill='%23a5000e' cx='0' cy='0' r='1100'/%3E%3Ccircle fill='%2398001c' cx='0' cy='0' r='1000'/%3E%3Ccircle fill='%238b0027' cx='0' cy='0' r='900'/%3E%3Ccircle fill='%237e0030' cx='0' cy='0' r='800'/%3E%3Ccircle fill='%23710037' cx='0' cy='0' r='700'/%3E%3Ccircle fill='%2364003b' cx='0' cy='0' r='600'/%3E%3Ccircle fill='%2358003c' cx='0' cy='0' r='500'/%3E%3Ccircle fill='%234b003a' cx='0' cy='0' r='400'/%3E%3Ccircle fill='%233e0037' cx='0' cy='0' r='300'/%3E%3Ccircle fill='%23310030' cx='0' cy='0' r='200'/%3E%3Ccircle fill='%23210024' cx='0' cy='0' r='100'/%3E%3C/g%3E%3C/svg%3E"); background-attachment: fixed; background-size: cover; overflow-x: hidden; } .cont { color: #ffffff; width: 500px; margin: auto; } h2 { color: #ffffff; text-align: center; padding: 1.5px; } .error { text-align: center; padding: 20px; font-size: 1rem; color: rgb(233, 76, 76); } form { font-size: 1.2rem; /* width: 40%; */ /* margin: auto; */ } .in{ margin: 5px 0; } input { border: 2px solid white; padding: 10px; margin: 5px 0; font-size: 1rem; width: 100%; } input:hover { border: 2px solid rgb(228, 81, 81); cursor: text; } p,a{ text-align: center; font-size: 1rem; } a{ color: deepskyblue; font-size:20px; } #s{ text-decoration:none; border-radius: 12px; } #s:hover { cursor: pointer; } a { text-decoration: none; } @media only screen and (max-width: 600px){ .cont{ width: 300px; } .error,input{ font-size: 0.8rem; } } @media only screen and (max-width: 400px){ .cont{ width: 70%; } h2{ font-size: 1.3rem; } a,p{ font-size: 0.7rem; } label{ font-size: 1.0rem; } input{ padding: 4px; } } </style> </head> <body> <?php $name=""; $email=""; $tel=""; $dob=""; $err=""; $name_err=""; $email_err=""; $tel_err=""; $dob_err=""; $password_err=""; if($_SERVER["REQUEST_METHOD"]=="POST") { if(isset($_POST['signup'])) { if(empty($_POST['name']) || empty($_POST['dob']) || empty($_POST['tel']) || empty($_POST['email']) || empty($_POST['password'])) { if(empty($_POST['name'])) { $name_err="Name is required!"; } else{ $name=$_POST['name']; } if(empty($_POST['email'])) { $email_err="Email is required!"; } else{ $email=$_POST['email']; } if(empty($_POST['tel'])) { $tel_err="Contact Number is required!"; } else{ $tel=$_POST['tel']; } if(empty($_POST['dob'])) { $dob_err="D.O.B is required!"; } else{ $dob=$_POST['dob']; } if(empty($_POST['password'])) { $password_err="Password is required!"; } } else { $today = new DateTime(date('m.d.y')); $dob = new DateTime($_POST['dob']); $diff1 = $today->diff($dob); $age = $diff1->y; if($age > 15 || $age <3) { $dob = $_POST['dob']; $dob_err = "Age criteria not satisfied , child's age must be between 3-15 years"; } else { require_once("./all_utils/connection.php"); $email=$_POST['email']; $query="SELECT * FROM identity_table WHERE email='".$email."'"; $result=mysqli_query($conn,$query); if(mysqli_fetch_assoc($result)) { $err="Email alredy registered!"; $name=$_POST['name']; $email=$_POST['email']; } else { if($age < 7) { $_SESSION['age_category'] = '1'; } else { $_SESSION['age_category'] = '2'; } $_SESSION['name']=$_POST['name']; $_SESSION['email']=$_POST['email']; $_SESSION['password'] = password_hash($_POST['password'],PASSWORD_DEFAULT); $_SESSION['tel']=$_POST['tel']; $_SESSION['dob']=$_POST['dob']; $_SESSION['xyz']='xyz'; require_once("all_utils/mail.php"); header("location:conf.php"); } } } } } ?> <div class="cont"> <h2>SignUp - Kanha Stories</h2> <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>" method="POST"> <span class="error"><?php echo $err; ?></span> <br/> <label for="name">Name</label><br /> <input type="text" name="name" placeholder="Enter your name" value="<?php echo $name; ?>"> <span class="error"><?php echo $name_err; ?></span> <br/> <label for="email">Email</label><br /> <input type="email" name="email" placeholder="Enter your Email ID" value="<?php echo $email; ?>"> <span class="error"><?php echo $email_err;?></span> <br/> <label for="tel">Mobile Number</label><br /> <input type="tel" name="tel" placeholder="Enter Mobile Number" value="<?php echo $tel; ?>"> <span class="error"><?php echo $tel_err;?></span> <br/> <label for="date">D.O.B. of Child (Click on Calander icon)</label><br /> <input type="date" name="dob" placeholder="Enter date of birth " value="<?php echo $dob;?>"> <span class="error"><?php echo $dob_err;?></span> <br/> <label for="password">Password</label><br /> <input type="password" name="password" placeholder="Enter your Password"> <span class="error"><?php echo $password_err; ?></span> <br/> <div class="sub"> <input type="submit" name="signup" id="s" placeholder="Submit"><br /> </div> </form> <p>Already registered? <a href="./login.php">log in here</a></p> </div> </body> </html>
I don't know what I can do now , Please try to give me the solutions as soon as possible. Thanks I keep getting an error code when running my php, it states: Parse error: syntax error, unexpected $end in W:\www\blog\login.php on line 33 Line 33 is </html> Code: [Select] <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Login</title> </head> <body> <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $pass = $_POST['password']; $result = mysql_query("SELECT * FROM users WHERE name='$name' AND pass='$pass'"); $num = mysql_num_rows($result); if($num == 0){ echo "Bad login, go <a href='login.php'>back</a>"; }else{ session_start(); $SESSION ['name'] = $name; header("Location: admin.php"); } ?> <form action='login.php' method='post'> Username: <input type='text' name='name' /><br /> Password: <input type='password' name='password' /><br /> <input type='submit' name='sumbit' value='Login!' /> </form> </body> </html>Can any one advise me whats wrong? I am having issues with my website getting errors occasionally (not consistent, every 4th page or so). When I check the error log I get the following message: [04-Jun-2020 14:57:22 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /home/sitename/public_html/wp-includes/meta.php on line 964 99% of the time it is line 964, rarely it is line 960. I really dont think this has to do with memory size as our memory is set to 512M, I thought it might have been an issues with W3 total cache, but deactivating the plugin didn't seem to have any affect. Here is the meta.php code from line 949-964. if ( ! empty( $meta_list ) ) { foreach ( $meta_list as $metarow ) { $mpid = intval( $metarow[ $column ] ); $mkey = $metarow['meta_key']; $mval = $metarow['meta_value']; // Force subkeys to be array type. if ( ! isset( $cache[ $mpid ] ) || ! is_array( $cache[ $mpid ] ) ) { $cache[ $mpid ] = array(); } if ( ! isset( $cache[ $mpid ][ $mkey ] ) || ! is_array( $cache[ $mpid ][ $mkey ] ) ) { $cache[ $mpid ][ $mkey ] = array(); } // Add a value to the current pid/key. $cache[ $mpid ][ $mkey ][] = $mval; I am fairly new to this so any help is really appreciated as I am just trying to help fix my family's business website
Thanks! Hi, when I run my script I get the following error message. These are array variables I am passing into the playerAttack function. I can't figure out what is wrong it looks fine to me. Any help greatly appreciated. Thanks. Derek Code: [Select] attack posted Fatal error: Cannot use string offset as an array in C:\wamp\www\SUN_DRAGON_GAME\gamestart.php on line 202 Code: [Select] $currentMonster='octalisk'; ///////////////////////////////////////////////////////////battle//////////////////////////// //function monsterEncounter($echoMonster,$monsterImage) if(!empty($_POST['attack'])) { echo "attack posted"; playerAttack($currentMonster,$player['stats']['playerHitRollLow'],$player['stats']['playerHitRollHigh'], $player['stats']['playerDmgLow'],$player['stats']['playerDmgHigh'],$monsters['Ocean']['octalisk']['defense'],$monster['Ocean']['octalisk']['hp'],$player['faction']['Teardrop_Ocean_Protectors']); $doesItAttack=encounter($monsters['ocean']['octalisk']['seeInvis'],$monsters['ocean']['octalisk']['aggro'],$player['factions']['Teardrop_Ocean_Protectors']); //insert octalisk stats into monsterattack function. if($doesItAttack =='yes') { monsterAttack($currentMonster,$monsters['Ocean']['octalisk']['hitRollLow'],$monsters['Ocean']['octalisk']['hitRollHigh'] , $monsters['Ocean']['octalisk']['dmgLow'],$monsters['Ocean']['octalisk']['dmgHigh'], $player['stats']['playerDefense'],$player['stats']['playerHp'],$monsters['Ocean']['octalisk']['hp']); } else { echo "do nothing"; } } here is the attack function Code: [Select] function playerAttack($currentMonster,$hitRollLow,$hitRollHigh,$dmgLow,$dmgHigh,$monsterDefense, $monsterHp,$playerFaction) { echo "in player attack"; $playerRoll= rand($playerHitRollLow, $playerHitRollHigh); if($playerHitRoll>=$monsterDefense) { global $theMessage; //shit had to make it global $playerDamage= rand($playerDmgLow,$playerDmgHigh); $theMessage = "You have hit a ". $currentMonster." for "."<strong>". $playerDamage."</strong> points of damage!"; $monsterHp= $monsterHp- $playerDamage; $theMessage.=" The ".$currentMonster."'s hp is now ".$monsterHp; if($monsterHp<=0) { if($playerFaction<=0) { $theMessage="Your faction standing with ".$playerFaction. "could not possibly get any worse."; } } $theMessage.=" You have killed the ".$currentMonster. "Your faction standing with ".$playerFaction." is now ".$playerFaction-1; } else { global $theMessage; //WTF i dont know what im doing. $theMessage= " Whoa! You missed the ".$currentMonster; } } Can anyone help me with this error? Fatal error: Call to a member function require_login() on a non-object in /home/wallls/public_html/index.php on line 27 Lines 26-33 below: <?php $smilek = $_GET['id']; $ppalout = $_GET['payout']; $healthy = array("%", "!", "=", "'", ",", "OR", "?", "<", "&", ";"); $yummy = array("", "", "", "", "" ,"", "", "", "", ""); $peee = str_replace($healthy, $yummy, $smilek); $chnpay = str_replace($healthy, $yummy, $ppalout); require_once 'appinclude.php'; require_once 'mystyle.php'; echo '<div align="center"><img src="'.$appcallbackurl.'main.png" width="300" height="150"></div>'; require_once 'ads/topads.php'; ?> <fb:tabs> <fb:tab-item href='<? echo $appCanvasUrl; ?>' title='Lottery' selected='true' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>earn.php' title='Get Tickets' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>payment.php' title='Payment Info' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>history.php' title='Lottery History' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>forum.php' title='Forum' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>invite.php' title='Invite Friends' /> </fb:tabs> <div align="center"> <? $fbid = $facebook->require_login(); $theirip = $_SERVER['REMOTE_ADDR']; if ($fbid == "") { ?>
Hello everyone Hi there, I have a local server set up on my computer which I have used before and it worked flawlessly. It is running apache with PHPand mySQL set up as services. Recently I attempted to copy a project I have worked on at school onto my server. I have the database up and running, however when I try to run a PHP file it gives me the error: Quote Fatal error: Cannot redeclare getText() in C:\Server\htdocs\projects\tournament\includes\functions.php on line 20 When I rename that function (which I know is not being redeclared) I get a browser error: Quote This webpage is not available. The webpage at http://localhost/projects/tournament/index.php might be temporarily down or it may have moved permanently to a new web address. More information on this error Below is the original error message Error 101 (net::ERR_CONNECTION_RESET): Unknown error. Has anybody else experienced this error and have a solution to fix it? My guess is that it has to do with the function gettext() being available on this machine but not on the machine at school, however I thought PHP was case sensitive? Hi everyone, I get this error: Catchable fatal error: Object of class Category could not be converted to string The code: public static function list_all_cat_names() { $result_array = self::find_by_sql("SELECT name FROM ".self::$table_name); return !empty($result_array) ? array_shift($result_array) : false; } $categories = Category::find_all(); foreach ($categories as $cats): echo $cats; endforeach; Where could be the problem? I have the following script: <?php $tijd[] = '2012-05-23T02:00:00'; $date = new DateTime($tijd[0]); echo $date; ?> However it is not working and resulting in: Quote Catchable fatal error: Object of class DateTime could not be converted to string in time3.php on line 7 I think to solve this issue, I have to convert $tijd[0] into a string. Right? If this is correct, how do I do that?
<!DOCTYPE html>
{ I'm getting this error for a blog script that is on my site :- PHP Fatal error: Uncaught TypeError: Unsupported operand types: string - int
The line in questions is this :- $prev = $page - 1; If I comment out this block of code the blog appears (with other errors, but I'll move on to those if I can fix this first!).
/* Setup page vars for display. */
Any idea's on what's needed to fix this script? I've contacted the original author but they haven't got back to me, I guess PHP8 maybe a little too new for them. Thanks for any help....
Here is the code: // Count files function filecount($FolderPath) { $filescount = 0; // Open the directory $dir = opendir($FolderPath); // if the directory doesn't exist return 0 if (!$dir){return 0;} // Read the directory and get the files while (($file = readdir($dir)) !== false) { if ($file[0] == '.'){ continue; } //if '.' it is a sub folder and call the function recursively if (is_dir($FolderPath.$file)){ // Call the function if it is a folder type $filescount += filecount($FolderPath.$file.DIRECTORY_SEPARATOR); } else { // Increment the File Count. $filescount++; } } // close the directory closedir($dir); return $filescount; } function getfilenames($location) { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($location); // open directory and walk through the filenames while ($file = readdir($handler)) { // if file isn't this directory or its parent, add it to the results if ($file != "." && $file != "..") { $results[] = $file; } } // tidy up: close the handler closedir($handler); // done! return $results; } function readfile($file) { $fh = fopen('./Data/' . $file, 'r'); $data = fread($fh, filesize($file)); fclose($fh); return $data; } Now, when I try to get the text from a textfile via the function readfile I get this error: Quote Fatal error: Cannot redeclare readfile() in ***Path\FileManagement.php on line 62 Whats wrong? Regards Worqy I am trying to create a class and I ran into a problem. The connect function is returning a fatal error on the line below and I can't figure out the issue. $result = $this->conn->query("SELECT unit FROM address");
class database { private $server = "localhost"; private $db_user = "my user"; private $db_pass = "my pass"; private $db_name = "my database"; private $conn; private $result = array(); function connect(){ // Create connection $this->conn = new mysqli($this->server, $this->db_user, $this->db_pass, $this->db_name); if ($this->conn->connect_error) { echo "Not connected, error: " . $mysqli_connection->connect_error; } else { //echo "Connected."; return $this->conn; } public function displayHeader(){ $result = $this->conn->query("SELECT unit FROM address"); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo '<li>' . $row["unit"] . '</li>'; } } else { echo "0 results"; } $conn->close(); } } }
Something strange is happning, line producing the error: if( ($this->subject == "") || ($this->message == "") ){ Any ideas guys? thanks lots!! 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 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 |