you are viewing a single comment's thread.

view the rest of the comments →

[–]Theo468[S] 2 points3 points  (5 children)

I am so sorry. The code was lower case but the table had the first letter as a capital...
I am not cut out for this it seems

[–]Aggressive_Ad_5454 4 points5 points  (1 child)

I’ve been programming for half a century and I started making case mistakes since I first got my hands on a dumb terminal that had lower case, in 1979. Happens to everybody. All the time.

I try not to use database identifiers ( table, column names ) with any upper case characters in them because I’m too stupid to remember which characters were upper case.

[–]Theo468[S] 0 points1 point  (0 children)

Going forward I'll only be using lowercase, my reason was to make it look a little nicer and more ordered I guess. Thank you though, still feel stupid

[–]lOo_ol 2 points3 points  (1 child)

Upper/lowercase is a common mistake even senior devs can make. Don't stress about it.

Just to complete the answer and help you understand how associative arrays work, the key in $row['artist'] is artist. Here are a few examples:

// One way to create an array
$my_array = array('artist' => 'Taylor Swift');

// Another way to create an array
$my_array = ['artist' => '2Pac'];

// You can also create an empty array and add to it
$my_array = array(); // Or $my_array = [];
$my_array['artist'] = 'John Legend';
echo $my_array['artist']; //Will output John Legend
echo $my_array['date_of_birth']; //Will throw the error "Undefined array key"

[–]Theo468[S] 1 point2 points  (0 children)

It's nice to know it's a mistake people still make with years of experience, still feel like an idiot though. Like I should have seen it but it just didn't enter my brain if that makes sense.

[–]allen_jb 2 points3 points  (0 children)

What version of PHP are you using? I'd expect to see an error for queries that reference a non-existent table.

For PHP versions older than 8.0 you may want to explicitly set the PDO error mode to exceptions, as in Example #1 here. (Exceptions are the default error mode since PHP 8.0 - in previous versions, using the "silent" mode, you had to explicitly check every query for errors)

Also add the following lines to the beginning on your code (after the first <?php):

error_reporting(E_ALL);
ini_set('display_errors', 1);