Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter - How to check if there is anything in the validation_error array

I'm wanting to display a general error message if there are any errors in the validation_errors() array, but if I do something like

if(isset(validation_errors())) { echo 'error'; }

then it returns back and says:

Fatal error: Can't use function return value in write context

Any help would be grand.

like image 227
Cecil Avatar asked Mar 06 '11 07:03

Cecil


2 Answers

if(validation_errors() != false) { echo 'error'; }

isset is used to Determine if a variable is set and is not NULL

Read http://php.net/manual/en/function.isset.php

like image 128
Gaurav Avatar answered Nov 14 '22 20:11

Gaurav


Just echo vadidation_errors()

It will output if there are errors, and nothing if no errors. You don't need if

like image 28
CappY Avatar answered Nov 14 '22 20:11

CappY