well I'm trying to hack som free script that I found on the internet but i can't get it to work.
For the moment I managed to get this output:
HTML OUTPUT:
errorsArray
(
[0] => Array
(
[0] => username
[1] => test
[2] => 14
)
)
==end of output
=> username = the field that triggered the error
=> test = some free param I pass along to use later in my coding
=> 14 = the number of the error in an external file that contains all my error msg.
THE PROB: how can I uset the 14 to get my error msg from my external file. if I already managed to load the file in my script.
here are the functions I used:
function load_messages = to include the external file that contains the $error = array (.. error msgs.
function _errors allows me to add errors info if a form validation check fails.
function get_errors_message gives the multi dimentional array with all info about the errors that occured.
Code: Select all
<?php
function load_messages()
{
$file = "error_msg.php";
if(file_exists($file))
{
include_once ($file);
foreach ($error as $key => $value)
{
$this->_messages[$key] = $value;
}
clearstatcache();
if (!isset($this->_messages[999999]))
{
return false;
}
return true;
}else{
clearstatcache();
return false;
}
}
function _errors($_field, $_data, $_error)
{
if (!empty($_field))
{
$this->_errors[] = array($_field,$_data,$_error);
}else{
$this->_errors[] = array($_data,$_error);
}
}
function get_errors_message()
{
if($this->load_messages())
{
$count = count ($this->_errors);
for ($x=0; $x<$count; $x++)
{
if (@$this->_messages[$this->_errors[$x][1]])
{
$this->_errors[$x][1] = $this->_messages[$this->_errors[$x][1]];
}else{
$this->_errors[$x][1] = $this->_messages[999999];
}
}
return $this->_errors;
}else{ // failed to load messages, at some point return something else...?
return $this->_errors;
}
}
?>thx for any help on this
siech