Hello every! I'm having some issues trying to pull data from a table. I need to pull data under the following constraints:

The PRINTNAME column can not be NULL and can not be empty, plus the DISABLED field needs to be 0.

This is what I have now, but I still get row returned that have empty strings in the PRINTNAME column.

$query = "select * from $tbl_name where (PRINTNAME IS NOT NULL OR PRINTNAME != '') AND DISABLED = '0' ";

I'm using PHP with MSSQL. I've tried Googling this but have not found much help. Any help from here would be great!

Thank you!

Try:

$query = "select * from $tbl_name where (PRINTNAME IS NOT NULL AND PRINTNAME <> '' AND Cast(PRINTNAME as varbinary) <> 0x) AND DISABLED = '0' ";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.