• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Having trouble with PDO queries (Notice: Undefined index)

phppdo


PHP Snippet 1:

$row = $resultBySQL->fetchAll(PDO::FETCH_ASSOC);

PHP Snippet 2:

//notice the 'fetch' in place of 'fetchAll'
while ( $row = $resultBySQL->fetch(PDO::FETCH_ASSOC); ) 
{
    $user = new User();
    $user->setUsername($row['username']);

    //...
}

PHP Snippet 3:

$rows = $resultBySQL->fetchAll(PDO::FETCH_ASSOC);

foreach( $rows as $row )
{
    $user = new User();
    $user->setUsername($row['username']);

    //...
} 

Related Snippets

Sentry + Laravel: how to log an already catched Exception?

How to install LDAP in Docker php-fpm alpine

How to programmatically find public properties of a class from inside one of it's methods

how to identify the web server name of remote host

Add 2 Webcam in one page with WebcamJS

PHP drop down list using array's and foreach (else and for) code

Popup Window and PHP form

PHP Include for HTML?

Only on Firefox "Loading failed for the <script> with source"

JQuery content editable div and text box on submit not sending POST

advanced custom fields wordpress custom class

PHP Slim Framework request using withAttribute error

PHP AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

Could not decode a text frame as UTF-8.

Redirect to previous page with php

About Contact Privacy policy Terms and conditions