-1
Good,
I have a doubt..
I’m using error system[] in array. I created a function that simply shows the design of the error + message
warning_alert('Caracteres do tituto superiores a 4.');
function warning_alert($text) {
echo "
<div class='alert warning'>
<span class='closebtn'>×</span>
<strong><i class='fas fa-exclamation-circle'></i></strong> $text
</div>";
}
This is where it says the ERROR message. But it’s not working...
$errors[] = warning_alert('Caracteres do tituto superiores a 4.');
This is the error message :
if(strlen($ads_title) < 4 && strlen($ads_title) > 35) {
$errors[] = warning_alert('Caracteres do tituto superiores a 4.');
}
Array errors works this way.
if(!empty($errors)) {
echo display_errors($errors);
} else {
if(move_uploaded_file($file_tmp, $file_destination)) {}
Any idea?
show error where??? what are you doing that does not show error?
– novic
not... This way does not give... $errors[] = warning_alert('Title characters greater than 4.'); It is as if no errors are heard...
– user21312321
Understand, I explained right up to... the $Errors[] array is where it shows all the errors of each check... but I want to show the error as I did, because WARNING_ALERT is a function with "ECHO $mensamgem"
– user21312321
I’ve edited, see now if you understand!
– user21312321
first, if you don’t need to store in an array! second inside a function you should return with Return and outside call
echo warning_alert("");
then your code isn’t working because there are conceptual errors !!!– novic
Can you correct me?... so I learn..
– user21312321
But.. I still need $errors [] = because it’s part of the system, and I can’t use ECHO
– user21312321
why? you need the
$erros[]
? that is not in your question the main reason! , is a confusing question!– novic
I already edited, see the ERROR message!
– user21312321
with your code only this works (even having problems)
if(strlen($ads_title) < 4 && strlen($ads_title) > 35) {
 warning_alert('Caracteres do tituto superiores a 4.'); 
}
– novic
Understand... I have to use $errors[] because it validates in another check. There is no way to Use Array $errors + function?????????????
– user21312321
Switch echo to Return in its function. I don’t know what the function that displays the data looks like, maybe you need to move it too.
– bfavaretto