PHP query is not working.
I'm building a browser based app using mysql, php, and apache. I have so far had really good success querying the db using php. I have a series of tables I am having problems with. the table names are sidea, sideb through sideh. I get no results when using this select 'select * from sidea where catalognumber = ''; while($row1 = $result->fetch_assoc()) { echo "Catalog Number: ". $row1[catalognumber]; I get the 'Catalog Number: but no the data if I use SELECT * from sidea where sideAidx = 2 it looks like this in the browser (chrome) SELECT * from sidea where sideAidx = 2 Catalog Number:
I can search other tables like tracks, records, bands without issue.
Did I make a mistake when I created the db, I used the following? CREATE TABLE `records`.`sidea` ( `sideAidx` TINYINT(3) NOT NULL , `LableCode` VARCHAR(30) NOT NULL , `LableCode2` VARCHAR(30) NOT NULL , `MatrixCode` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode2` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode3` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode4` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode5` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode6` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode7` VARCHAR(20) NULL DEFAULT NULL , `MatrixCode8` VARCHAR(20) NULL DEFAULT NULL , `Stamp` VARCHAR(20) NULL DEFAULT NULL , `Stamp1` VARCHAR(20) NULL DEFAULT NULL , `Stamp2` VARCHAR(20) NULL DEFAULT NULL , `CatalogNumber` VARCHAR(40) , `BandCode` INT(10) NOT NULL , PRIMARY KEY (`sideAidx`)) ENGINE = InnoDB;
Has anyone encountered this in the past?
Thank You.
Answer Answered by Daniel Black in this comment.
Try to keep using consistent case with column names so use the mixed case for CatalogNumber. Check the php error log to see if something occurred in the query being in error rather than the result set.
Your multiple side database with multiple columns for MatrixCode looks odd as this is normally done in multiple tables with JOINs. Relook at the structure if the SQL you are writing is seeming abnormally complex.