I need a second set of eyes. Not getting the correct data returned.

I have the following code:

                       echo "RowCon1 = ".$ROW_bld2['OWCN1']."<br>";
                  $Contact1 = $ROW_bld2['OWCN1'];
                  echo "Contact1 = ".$Contact1."<br>";
                  if ($Contact1 == "    ")
                  {
                        $Contact1 = "0000";
                  }
                  echo "Contact1 = ".$Contact1."<br>";
                  
                  echo "RowCon2 = ".$ROW_bld2['OWCN2']."<br>";
                  $Contact2 = $ROW_bld2['OWCN2'];
                  echo "Contact2 = ".$Contact2."<br>";
                  if ($Contact2 == "    ")
                  {
                        $Contact2 = "0000";
                  }
                  echo "Contact2 = ".$Contact2."<br>";

My query is correct and is returning the correct record.  I've checked the data and OWCN1 is "0001" and OWCN2 is "0000".  Contact1 works and returns the correct data.  The displays for Contact2 returns "    "?
What am i missing?
breeze351Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
you have  if ($Contact2 == "    ")

it should be  if ($Contact2 == "0000")

because in your code  if ($Contact2 == "    ") means BLANK not zeros
0
breeze351Author Commented:
Nope.  
1: if ($Contact2 == "0000") then I don't have to change it to "0000"
2: $ROW_bld2['OWCN2'] is returning blanks.  The table show OWCN2 as being "0000".
0
plusone3055Commented:
sorry  my friend
thought I had it there.. Maybe i need to take my eyes away form the screen :(
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

breeze351Author Commented:
I added a var_dump on OWCD2 and I get the same result.
0
Dan CraciunIT ConsultantCommented:
Maybe the wrong number of spaces?
Try
if (trim($Contact2) == "")
                  {
                        $Contact2 = "0000";
                  }

Open in new window

HTH,
Dan
0
Marco GasiFreelancerCommented:
SOrry, breeze, I don't see anything different between the two block of code, but I wich ask a question: why you're using 4 blank spaces to check the value? Or yoiu use the TAB? This can sometims make a difference... And why don't you use just if (empty($Contact2))?
0
breeze351Author Commented:
Its 4 blanks and I tried empty and I got the same results!
0
breeze351Author Commented:
But it's not empty!!!

This is whats returned from php:

String3 = SELECT * FROM bld2 WHERE SEQ = "NY1046000400"
string(4) "0001" dump con1 =
string(0) "" dump con2 =
Owner = 00003739
RowCon1 = 0001
Owner_Contact_1 = 0001
Owner_Contact_1 = 0001
RowCon2 =
Owner_Contact_2 =
Owner_Contact_2 =

The attached file has the screen print from the MySql query.

As you can see OWCN2 = "0000"!!  WTF!
Query-print.doc
0
Dan CraciunIT ConsultantCommented:
Try identical instead of equal. If typecasting, 0 and the empty string will both be equal to false.

if ($Contact2 === "    ")
0
breeze351Author Commented:
You guys are missing the point!   It's not the if statement.  $ROW_bld2['OWCN2'] is returning blank!!!!  I can comment out the if statement nothing changes.  $ROW_bld2['OWCN2'] is not in the if statement.
0
Ray PaseurCommented:
Please use var_export($ROW_bld2) and post the results here, thanks.
0
breeze351Author Commented:
Here's the dump:
array ( 0 => 'NY1046000400', 'SEQ' => 'NY1046000400', 1 => '', 'BLID' => '', 2 => '', 'MTC1' => '', 3 => '', 'MTC2' => '', 4 => '', 'MTC3' => '', 5 => '', 'MTC4' => '', 6 => '', 'MTC5' => '', 7 => '', 'MTC6' => '', 8 => '', 'TRUOWN' => '', 9 => '00003739', 'OWCDE' => '00003739', 10 => '0001', 'OWCN1' => '0001', 11 => '', 'OWCN2' => '', 12 => '', 'MGCDE' => '', 13 => '', 'MGCN1' => '', 14 => '', 'MGCN2' => '', 15 => '', 'LACDE' => '', 16 => '', 'LACN1' => '', 17 => '', 'LACN2' => '', 18 => '', 'LACN3' => '', 19 => '', 'LACN4' => '', 20 => '', 'BKCDE' => '', 21 => '', 'BKCN1' => '', 22 => '', 'BKCN2' => '', 23 => '', 'LESS' => '', 24 => '', 'MTN1' => '', 25 => '', 'MTN2' => '', 26 => '', 'MTN3' => '', 27 => '', 'MTN4' => '', 28 => '', 'MTN5' => '', 29 => '', 'MTN6' => '', 30 => '', 'FSBRK' => '', 31 => '', 'FSCON' => '', 32 => '', 'OWNR' => '', 33 => '', 'AGENT' => '', 34 => '', 'AGCNT' => '', 35 => '', 'AGPHN' => '', 36 => '', 'INIT_U' => '', 37 => '', 'UTYPE' => '', 38 => '', 'RECDATE' => '', 39 => '', 'RECTIME' => '', )

I see that OWCN2 is blank.  But why?  When I do the query in phpMyAdmin it shows as "0000".
0
breeze351Author Commented:
I just checked the structure.  OWCN1 and OWCN2 are both varchar(4).
0
Ray PaseurCommented:
Hmm... Looks like you may be using mysql_fetch_array().  That is one of the well-documented PHP antipractices.  Maybe switch to fetch_assoc() or fetch_object() and you will instantly get better performance.

Please see http://iconoun.com/demo/temp_breeze351.php
<?php // demo/temp_breeze351.php

/**
 * http://www.experts-exchange.com/questions/28704007/I-need-a-second-set-of-eyes-Not-getting-the-correct-data-returned.html
 */
error_reporting(E_ALL);
ob_start();
echo '<pre>';

$ROW_bld2 = array ( 0 => 'NY1046000400', 'SEQ' => 'NY1046000400', 1 => '', 'BLID' => '', 2 => '', 'MTC1' => '', 3 => '', 'MTC2' => '', 4 => '', 'MTC3' => '', 5 => '', 'MTC4' => '', 6 => '', 'MTC5' => '', 7 => '', 'MTC6' => '', 8 => '', 'TRUOWN' => '', 9 => '00003739', 'OWCDE' => '00003739', 10 => '0001', 'OWCN1' => '0001', 11 => '', 'OWCN2' => '', 12 => '', 'MGCDE' => '', 13 => '', 'MGCN1' => '', 14 => '', 'MGCN2' => '', 15 => '', 'LACDE' => '', 16 => '', 'LACN1' => '', 17 => '', 'LACN2' => '', 18 => '', 'LACN3' => '', 19 => '', 'LACN4' => '', 20 => '', 'BKCDE' => '', 21 => '', 'BKCN1' => '', 22 => '', 'BKCN2' => '', 23 => '', 'LESS' => '', 24 => '', 'MTN1' => '', 25 => '', 'MTN2' => '', 26 => '', 'MTN3' => '', 27 => '', 'MTN4' => '', 28 => '', 'MTN5' => '', 29 => '', 'MTN6' => '', 30 => '', 'FSBRK' => '', 31 => '', 'FSCON' => '', 32 => '', 'OWNR' => '', 33 => '', 'AGENT' => '', 34 => '', 'AGCNT' => '', 35 => '', 'AGPHN' => '', 36 => '', 'INIT_U' => '', 37 => '', 'UTYPE' => '', 38 => '', 'RECDATE' => '', 39 => '', 'RECTIME' => '', );
// var_dump($ROW_bld2);

// VISUALIZE THE TWO FIELDS
var_dump($ROW_bld2['OWCN1']);
var_dump($ROW_bld2['OWCN2']);

// REPLACE BLANK FIELDS WITH "0000"
if (trim($ROW_bld2['OWCN1']) == NULL) $ROW_bld2['OWCN1'] = '0000';
if (trim($ROW_bld2['OWCN2']) == NULL) $ROW_bld2['OWCN2'] = '0000';

// VISUALIZE THE TWO FIELDS
var_dump($ROW_bld2['OWCN1']);
var_dump($ROW_bld2['OWCN2']);

Open in new window

0
Ray PaseurCommented:
I see that OWCN2 is blank.  But why?  When I do the query in phpMyAdmin it shows as "0000".
The only possible explanation I can think of is that phpMyAdmin is looking at a different row.
0
breeze351Author Commented:
How can it be looking at a different row?  Did you see the screen print that I posted from phpMyAdmin that I sent before?  Don't I come up with some weird shit :)
0
Ray PaseurCommented:
No, sorry.  I could not open it.

But you might check the AUTO_INCREMENT key to see if the key numbers are the same.  I don't have that information.  With questions like this it's useful to post the CREATE TABLE statement(s) as well as the data that is in play.
0
Marco GasiFreelancerCommented:
It looks like 0000 be considered as NULL: does this make sense? Posting the CREATE TABLE statement(s) could help to help.
0
Ray PaseurCommented:
@Marco: Loose data typing always presents us with the risk that leading zeroes are truncated.  If you try to use a value like '05234' in a MySQL database, it will inevitably be interpreted as '5234' somewhere in the application.  This is something all experienced developers wrestle with at some point in their work - you want 05234 to collate lower than 11111, but it doesn't work out correctly.  Sorting rules are complicated in PHP, maybe so in MySQL, too.

Once our Author gives us the CREATE TABLE statements, we will be able to set up discreet tests to illustrate what is happening to the data.  My guess, and it's only a guess, is that loose data typing is doing exactly what you've said.  TRUE and FALSE are not canonical.  There are "truthy" and "falsy" values that can be substituted with (sometimes) surprising results.  Zero, NULL, empty(), undefined all mean the same as FALSE if the test is done with two equal signs.  Type coercion and loose data types can work together in ways that are not helpful all the time.

Here are the PHP references that reveal / conceal its ways of testing variables.  Perhaps missing from these references, but probably not in play here, are the issues surrounding comparison of objects, which is a bad design idea and should be avoided.  
http://php.net/manual/en/language.types.php
http://php.net/manual/en/types.comparisons.php
http://php.net/manual/en/language.operators.comparison.php
http://php.net/manual/en/language.types.type-juggling.php

I have not researched the MySQL part of it, but rather than research it, I think it would be best and easiest to simply test once we have the table definitions.
0
Brian TaoSenior Business Solutions ConsultantCommented:
Is it possible that you're connecting to another DB (a test one)? One reminder: use single quote instead of double quote in your SQL statement, so your string3 should be:
SELECT * FROM bld2 WHERE SEQ = 'NY1046000400'
0
breeze351Author Commented:
Here's the create:

CREATE TABLE `langsyst_retail`.`test_bld2` ( `SEQ` varchar( 12 ) DEFAULT NULL ,
`BLID` varchar( 10 ) DEFAULT NULL ,
`MTC1` varchar( 10 ) DEFAULT NULL ,
`MTC2` varchar( 10 ) DEFAULT NULL ,
`MTC3` varchar( 10 ) DEFAULT NULL ,
`MTC4` varchar( 10 ) DEFAULT NULL ,
`MTC5` varchar( 10 ) DEFAULT NULL ,
`MTC6` varchar( 10 ) DEFAULT NULL ,
`TRUOWN` varchar( 35 ) DEFAULT NULL ,
`OWCDE` varchar( 8 ) DEFAULT NULL ,
`OWCN1` varchar( 4 ) DEFAULT NULL ,
`OWCN2` varchar( 4 ) DEFAULT NULL ,
`MGCDE` varchar( 8 ) DEFAULT NULL ,
`MGCN1` varchar( 4 ) DEFAULT NULL ,
`MGCN2` varchar( 10 ) DEFAULT NULL ,
`LACDE` varchar( 8 ) DEFAULT NULL ,
`LACN1` varchar( 4 ) DEFAULT NULL ,
`LACN2` varchar( 10 ) DEFAULT NULL ,
`LACN3` varchar( 10 ) DEFAULT NULL ,
`LACN4` varchar( 10 ) DEFAULT NULL ,
`BKCDE` varchar( 8 ) DEFAULT NULL ,
`BKCN1` varchar( 4 ) DEFAULT NULL ,
`BKCN2` varchar( 4 ) DEFAULT NULL ,
`LESS` varchar( 10 ) DEFAULT NULL ,
`MTN1` va[...]

I've tried the code on another address where the OWCN2 is not all zeros and it worked correctly.  Here's the dump from that:

tring3 = SELECT * FROM bld2 WHERE SEQ = "NY1020001409"
array ( 0 => 'NY1020001409', 'SEQ' => 'NY1020001409', 1 => '', 'BLID' => '', 2 => '', 'MTC1' => '', 3 => '', 'MTC2' => '', 4 => '', 'MTC3' => '', 5 => '', 'MTC4' => '', 6 => '', 'MTC5' => '', 7 => '', 'MTC6' => '', 8 => '1409 2ND Avenue Corp', 'TRUOWN' => '1409 2ND Avenue Corp', 9 => '10017224', 'OWCDE' => '10017224', 10 => '0002', 'OWCN1' => '0002', 11 => '0001', 'OWCN2' => '0001', 12 => '', 'MGCDE' => '', 13 => '', 'MGCN1' => '', 14 => '', 'MGCN2' => '', 15 => '', 'LACDE' => '', 16 => '', 'LACN1' => '', 17 => '', 'LACN2' => '', 18 => '', 'LACN3' => '', 19 => '', 'LACN4' => '', 20 => '', 'BKCDE' => '', 21 => '', 'BKCN1' => '', 22 => '', 'BKCN2' => '', 23 => '', 'LESS' => '', 24 => '', 'MTN1' => '', 25 => '', 'MTN2' => '', 26 => '', 'MTN3' => '', 27 => '', 'MTN4' => '', 28 => '', 'MTN5' => '', 29 => '', 'MTN6' => '', 30 => '', 'FSBRK' => '', 31 => '', 'FSCON' => '', 32 => '', 'OWNR' => '', 33 => '', 'AGENT' => '', 34 => '', 'AGCNT' => '', 35 => '', 'AGPHN' => '', 36 => '', 'INIT_U' => '', 37 => '', 'UTYPE' => '', 38 => '', 'RECDATE' => '', 39 => '', 'RECTIME' => '', )string(4) "0002" dump con1 =
string(4) "0001" dump con2 =
Owner = 10017224
RowCon1 = 0002
Owner_Contact_1 = 0002
Owner_Contact_1 = 0002
RowCon2 = 0001
Owner_Contact_2 = 0001
Owner_Contact_2 = 0001

I read what you were saying about "0000" being interpreted as null or dropping the leading zeros.  My question is why isn't "0001" and "0002" in this example not being returned as "1" and "2" respectively?

Glenn
0
breeze351Author Commented:
Ray:

I used your "trim" code and it worked.   I'm using the original logic in other pages and it works, so I just did a copy and paste to this page.  Why would it work in the other pages?  The other pages are also querying bld2 for the same bulding address.

Glenn
0
Ray PaseurCommented:
Well, I can't tell you why something is or isn't working, but I can show you what PHP is doing with the data.  And I can share some ideas about best or at least better practices.  Without doing a research project, it looks to me like logic errors are coming from type juggling that changes data types in an attempt to create a useful loosely typed variable.

I like to define columns that might be empty as NOT NULL DEFAULT '' (two adjacent single quotes) because I find the PHP programming to be more straightforward.  The use of MySQL NULLs and PHP NULLs leads to easy confusion, so I just take that out of play.  You can run this script to see what PHP and MySQL are doing with strings that say '0000'.  Basically that can mean any of these values:
LAST ROW HAS ZERO (numeric zero)
LAST ROW HAS "0000"
LAST ROW HAS "000"
LAST ROW HAS "00"
LAST ROW HAS "0"

Open in new window

http://iconoun.com/demo/temp_breeze351.php
<?php // demo/temp_breeze351.php

/**
 * http://www.experts-exchange.com/questions/28704007/I-need-a-second-set-of-eyes-Not-getting-the-correct-data-returned.html
 */
/**
 * Demonstrate some of the basics of MySQLi
 *
 * References that must be understood to use PHP and MySQL(i)
 *
 * http://php.net/manual/en/mysqli.overview.php
 * http://php.net/manual/en/class.mysqli.php
 * http://php.net/manual/en/class.mysqli-stmt.php
 * http://php.net/manual/en/class.mysqli-result.php
 * http://php.net/manual/en/class.mysqli-warning.php
 * http://php.net/manual/en/class.mysqli-sql-exception.php <-- DID NOT WORK PHP 5.3+, MySQL 5.1+
 * http://php.net/manual/en/mysqli.construct.php
 * http://php.net/manual/en/mysqli.real-escape-string.php
 * http://php.net/manual/en/mysqli.query.php
 * http://php.net/manual/en/mysqli.errno.php
 * http://php.net/manual/en/mysqli.error.php
 * http://php.net/manual/en/mysqli.insert-id.php
 * http://php.net/manual/en/mysqli-result.num-rows.php
 * http://php.net/manual/en/mysqli-result.fetch-array.php
 * http://php.net/manual/en/mysqli-result.fetch-object.php
 */

// RAISE THE ERROR REPORTING LEVEL TO THE HIGHEST POSSIBLE SETTING
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
echo '<pre>';

// DATABASE CONNECTION AND SELECTION VARIABLES - GET THESE FROM YOUR HOSTING COMPANY
$db_host = "localhost"; // PROBABLY THIS IS OK
$db_name = "??";
$db_user = "??";
$db_word = "??";

// OPEN A CONNECTION TO THE DATA BASE SERVER AND SELECT THE DB
$mysqli = new mysqli($db_host, $db_user, $db_word, $db_name);

// DID THE CONNECT/SELECT WORK OR FAIL?
if ($mysqli->connect_errno)
{
    $err
    = "CONNECT FAIL: "
    . $mysqli->connect_errno
    . ' '
    . $mysqli->connect_error
    ;
    trigger_error($err, E_USER_ERROR);
}

// ACTIVATE THIS TO SHOW WHAT THE DB CONNECTION OBJECT LOOKS LIKE
// var_dump($mysqli);


// CREATING A TABLE FOR OUR TEST DATA
$sql
=
"
CREATE TEMPORARY TABLE my_table
( id    INT NOT NULL AUTO_INCREMENT PRIMARY KEY
, OWCN1 VARCHAR( 4) NOT NULL DEFAULT ''
, OWCN2 VARCHAR( 4) NOT NULL DEFAULT ''
, MGCDE VARCHAR( 8) NOT NULL DEFAULT ''
)
"
;

// IF mysqli::query() RETURNS FALSE, LOG AND SHOW THE ERROR
if (!$res = $mysqli->query($sql))
{
    $err
    = 'QUERY FAILURE:'
    . ' ERRNO: '
    . $mysqli->errno
    . ' ERROR: '
    . $mysqli->error
    . ' QUERY: '
    . $sql
    ;
    trigger_error($err, E_USER_ERROR);
}

// SHOW THE RESULTS OF THE QUERY
var_dump($res);


// LOADING TEST DATA INTO THE TABLE
$sql = "INSERT INTO my_table ( OWCN1, OWCN2 ) VALUES ( '0000', '0000' )";
if (!$res = $mysqli->query($sql))
{
    $err
    = 'QUERY FAILURE:'
    . ' ERRNO: '
    . $mysqli->errno
    . ' ERROR: '
    . $mysqli->error
    . ' QUERY: '
    . $sql
    ;
    trigger_error($err, E_USER_ERROR);
}

$mysqli->query( "INSERT INTO my_table ( OWCN1, OWCN2 ) VALUES ( '0001', '0001' )" );
$mysqli->query( "INSERT INTO my_table ( OWCN1, OWCN2 ) VALUES ( '0002', '0002' )" );
$mysqli->query( "INSERT INTO my_table ( OWCN1, OWCN2 ) VALUES ( '1001', '1001' )" );



// CREATE AND SEND A SELECT QUERY AND TEST THE RESULTS
$sql = "SELECT * FROM my_table WHERE OWCN1='0000' ";
$res = $mysqli->query($sql);

// IF mysqli_query() RETURNS FALSE, LOG AND SHOW THE ERROR
if (!$res)
{
    $err
    = 'QUERY FAILURE:'
    . ' ERRNO: '
    . $mysqli->errno
    . ' ERROR: '
    . $mysqli->error
    . ' QUERY: '
    . $sql
    ;
    trigger_error($err, E_USER_ERROR);
}
// IF WE GET THIS FAR, THE QUERY SUCCEEDED AND WE HAVE A RESULT OBJECT IN $res
// AND SO WE CAN NOW USE OTHER MYSQLI::RESULT PROPERTIES AND METHODS


// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
$num     = $res->num_rows;
$num_fmt = number_format($num);
if (!$num)
{
    echo PHP_EOL . "QUERY: $sql ";
    echo PHP_EOL . "FOUND NO DATA ";
}
else
{
    echo PHP_EOL . "QUERY: $sql ";
    echo PHP_EOL . "FOUND $num_fmt ROWS OF DATA ";
}
echo PHP_EOL;


// ITERATE OVER THE RESULTS SET AS AN OBJECT TO SHOW WHAT WE FOUND
echo PHP_EOL . 'USING MySQLi_Result::Fetch_<i>Object</i>(): ';
echo PHP_EOL;
while ($row = $res->fetch_object())
{
    // ROW BY ROW PROCESSING IS DONE HERE
    print_r($row);
    echo PHP_EOL;
}
echo PHP_EOL;



// CREATE AND SEND A SELECT QUERY AND TEST THE RESULTS
$sql = "SELECT * FROM my_table WHERE OWCN1 < 2";
$res = $mysqli->query($sql);

// IF mysqli_query() RETURNS FALSE, LOG AND SHOW THE ERROR
if (!$res)
{
    $err
    = 'QUERY FAILURE:'
    . ' ERRNO: '
    . $mysqli->errno
    . ' ERROR: '
    . $mysqli->error
    . ' QUERY: '
    . $sql
    ;
    trigger_error($err, E_USER_ERROR);
}
// IF WE GET THIS FAR, THE QUERY SUCCEEDED AND WE HAVE A RESULT OBJECT IN $res
// AND SO WE CAN NOW USE OTHER MYSQLI::RESULT PROPERTIES AND METHODS


// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
$num     = $res->num_rows;
$num_fmt = number_format($num);
if (!$num)
{
    echo PHP_EOL . "QUERY: $sql ";
    echo PHP_EOL . "FOUND NO DATA ";
}
else
{
    echo PHP_EOL . "QUERY: $sql ";
    echo PHP_EOL . "FOUND $num_fmt ROWS OF DATA ";
}
echo PHP_EOL;


// ITERATE OVER THE RESULTS SET AS AN OBJECT TO SHOW WHAT WE FOUND
echo PHP_EOL . 'USING MySQLi_Result::Fetch_<i>Object</i>(): ';
echo PHP_EOL;
while ($row = $res->fetch_object())
{
    // ROW BY ROW PROCESSING IS DONE HERE
    print_r($row);
    echo PHP_EOL;
}
echo PHP_EOL;



// CREATE AND SEND A SELECT QUERY AND TEST THE RESULTS
$sql = "SELECT * FROM my_table ORDER BY OWCN1 DESC ";
$res = $mysqli->query($sql);

// IF mysqli_query() RETURNS FALSE, LOG AND SHOW THE ERROR
if (!$res)
{
    $err
    = 'QUERY FAILURE:'
    . ' ERRNO: '
    . $mysqli->errno
    . ' ERROR: '
    . $mysqli->error
    . ' QUERY: '
    . $sql
    ;
    trigger_error($err, E_USER_ERROR);
}
// IF WE GET THIS FAR, THE QUERY SUCCEEDED AND WE HAVE A RESULT OBJECT IN $res
// AND SO WE CAN NOW USE OTHER MYSQLI::RESULT PROPERTIES AND METHODS


// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
$num     = $res->num_rows;
$num_fmt = number_format($num);
if (!$num)
{
    echo PHP_EOL . "QUERY: $sql ";
    echo PHP_EOL . "FOUND NO DATA ";
}
else
{
    echo PHP_EOL . "QUERY: $sql ";
    echo PHP_EOL . "FOUND $num_fmt ROWS OF DATA ";
}
echo PHP_EOL;


// ITERATE OVER THE RESULTS SET AS AN OBJECT TO SHOW WHAT WE FOUND
echo PHP_EOL . 'USING MySQLi_Result::Fetch_<i>Object</i>(): ';
echo PHP_EOL;
while ($row = $res->fetch_object())
{
    // ROW BY ROW PROCESSING IS DONE HERE
    print_r($row);
    echo PHP_EOL;

    // CHECK THE ZEROS IN THE LAST ROW
	if ($row->OWCN1 == 0)      echo PHP_EOL . 'LAST ROW HAS ZERO';
	if ($row->OWCN1 == FALSE)  echo PHP_EOL . 'LAST ROW HAS FALSE';
	if ($row->OWCN1 == '0000') echo PHP_EOL . 'LAST ROW HAS "0000"';
	if ($row->OWCN1 == '000')  echo PHP_EOL . 'LAST ROW HAS "000"';
	if ($row->OWCN1 == '00')   echo PHP_EOL . 'LAST ROW HAS "00"';
	if ($row->OWCN1 == '0')    echo PHP_EOL . 'LAST ROW HAS "0"';
	if ($row->OWCN1 == NULL)   echo PHP_EOL . 'LAST ROW HAS NULL';
	if (empty($row->OWCN1))    echo PHP_EOL . 'LAST ROW HAS EMPTY()';

}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
breeze351Author Commented:
Thanks:
Ray I'll try your scripts tomorrow.  It is just weird that one page handles it one way and the same code in another does something different.
Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.