2
$result = mysql_query('SELECT * FROM ACCOUNTING WHERE  ACCTSTATUSTYPE = "Start" AND Process_Status IS NULL LIMIT 10');
if($result === FALSE) 
{
    die(mysql_error());
}

The following code spits back

Unknown column 'Process_Status' in 'where clause'

However, when I copy and paste this query

SELECT * FROM ACCOUNTING WHERE ACCTSTATUSTYPE = "Start" AND Process_Status IS NULL LIMIT 10

directly into MySQL, it is successful.

I am a bit new to PHP/MySQL so do queries have to be worded differently when parsing them with PHP?

Thanks,

Matt

Matt
  • 1,490
  • 2
  • 17
  • 41
  • Strange ... Try to use backticks `SELECT * FROM ACCOUNTING WHERE \`ACCTSTATUSTYPE\` = "Start" AND \`Process_Status\` IS NULL LIMIT 10` – HamZa Apr 05 '13 at 00:10
  • 4
    Are you sure that you have the correct database selected? – Explosion Pills Apr 05 '13 at 00:10
  • 5
    Please stop using the MySQL extension. It has been deprecated. See [this SO question](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) for more information – Phil Apr 05 '13 at 00:10
  • 1
    do you have a column in that db table `ACCTSTATUSTYPE`? – Jhonathan H. Apr 05 '13 at 00:20
  • @HamZaDzCyberDeV Unfortunately this yielded no result. – Matt Apr 05 '13 at 00:21
  • @Kaii Yes. Pasting the query directly into MySQL produces the desired result. – Matt Apr 05 '13 at 00:22
  • The MySQL extension will throw E_DEPRECATED with the impending 5.5 release. – Sam Giles Apr 05 '13 at 00:22
  • 1
    @HamZaDzCyberDeV Backticks are only needed if the column name is a reserved word or contains non-alphanumerics. Also, it would be needed in the command line, too. – Barmar Apr 05 '13 at 00:22
  • I can only assume @ExplosionPills is correct and your PHP script is looking at a different database. How have you confirmed the settings are the same? – Phil Apr 05 '13 at 00:24
  • @Phil I have confirmed the Database in the config.inc file and have double checked the connect to database function in my index.php file. It is definitely pointing to localhost > radiator and from there I select from Accounting. – Matt Apr 05 '13 at 00:32
  • @Phil Well you were correct. I was pointing to our production database instead of our test database (lol). Thanks. – Matt Apr 05 '13 at 01:23
  • @Barmar thanks for the constructive feedback ! – HamZa Apr 05 '13 at 09:17

0 Answers0