Jump to content

Recommended Posts

I have the following php code that errors as indicated:

$query = $con->query('SELECT FILENAME, country, area, city FROM download WHERE FILENAME is not null');

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'country' in 'field list' in /home/larry/web/test/public_html/report1.php:47 Stack trace: #0 /home/larry/web/test/public_html/report1.php(47): PDO->query('SELECT FILENAME...') #1 {main} thrown in /home/larry/web/test/public_html/report1.php on line 47

The Select statement doesn't error when run in mysql shell or phpmyadmin. Here's the result of show create table download:


localhost/test/download/        http://localhost/phpmyadmin/tbl_sql.php?db=test&table=download&token=5739c407033be3e118287bc7a9041c2c
 Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available. 

Your SQL query has been executed successfully.

show create table download

download    CREATE TABLE `download` (
  `ID` int(5) NOT NULL AUTO_INCREMENT,
  `LOG_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `IP_ADDRESS` int(64) unsigned NOT NULL,
  `FILENAME` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL,
  `country` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL,
  `area` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL,
  `city` varchar(50) COLLATE utf8_general_mysql500_ci DEFAULT NULL,
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1266 DEFAULT CHARSET=utf8 COLLATE=utf8_general_mysql500_ci    

Does anyone have an idea why this is happening?

On 5/4/2020 at 2:55 PM, larry29936 said:

It was connecting to the production db

I think you may have had a "Lucky Escape" here.

Your code failed on the "select".  It might be that you have a "delete" statement a few lines further down ...   If so, you would have been removing "real" Data from your Live database!

You need to find a way to prevent this "cross-Environment" connectivity from happening again. 

Regards, 
   Phill  W.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.