TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Array confusion (http://www.talkphp.com/absolute-beginners/1208-array-confusion.html)

Haris 09-22-2007 10:52 PM

Array confusion
 
Yes, I confused myself with Arrays.

PHP Code:

Array
(
    [
0] => Array
        (
            [
field] => szUsername
            
[value] => 
            [
error] => Please enter a username
        
)

    [
1] => Array
        (
            [
field] => szPassword
            
[value] => 
            [
error] => Please enter a password
        
)



How do I out the error only?

Current code:

PHP Code:

    if($this->aErrors){
        echo 
'<div id="error">';
        echo 
'<ul>';
        foreach(
$this->aErrors as $iKey => $szValue){
                echo 
'<li>'.$szErrors['error'].'</li>';
        }
        echo 
'</ul>';
        echo 
'</div>';
    }
    
    echo 
'<pre>'.print_r($this->aErrors1); 


Haris 09-22-2007 10:56 PM

Lol, I fixed it.

Confusion, confusions. :(

PHP Code:

    if($this->aErrors){
        echo 
'<div id="error">';
        echo 
'<ul>';
        foreach(
$this->aErrors as $iKey => $szValue){
                echo 
'<li>'.$szValue['error'].'</li>';
        }
        echo 
'</ul>';
        echo 
'</div>';
    } 

Thanks Adam, in advance.

Wildhoney 09-22-2007 10:57 PM

Looks all good apart from this line:

PHP Code:

echo '<li>'.$szErrors['error'].'</li>'

I don't know where you're getting $szErrors from, it should be:

PHP Code:

echo '<li>'.$szValue['error'].'</li>'



All times are GMT. The time now is 03:09 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0