By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

mysql null field values not being returned

P: n/a
is there a workaround for rows with null values not being returned? I am
using PHP 4.3.2 and mysql. the mysql_fetch_array just seems to ignore some
of the latest rows with null values.
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Fri, 5 Sep 2003 16:51:03 +0100, "Lance" <la**********@hotmail.com> wrote:
is there a workaround for rows with null values not being returned? I am
using PHP 4.3.2 and mysql. the mysql_fetch_array just seems to ignore some
of the latest rows with null values.


Post code demonstrating the problem? Can't reproduce it here.

mysql> select * from test1;
+------+
| c |
+------+
| a |
| b |
| NULL |
+------+
3 rows in set (0.00 sec)

<pre>
<?php
$conn = mysql_connect('localhost', 'andyh', 'stp40lnk') or die('connect: ' .
mysql_error());
mysql_select_db('testdb') or die('select db: ' . mysql_error());

$res = mysql_query('select * from test1;')
or die(mysql_error());

while ($row = mysql_fetch_array($res))
var_dump($row);
?>
</pre>

Output:

array(2) {
[0]=>
string(1) "a"
["c"]=>
string(1) "a"
}
array(2) {
[0]=>
string(1) "b"
["c"]=>
string(1) "b"
}
array(2) {
[0]=>
NULL
["c"]=>
NULL
}

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #2

P: n/a
On Fri, 5 Sep 2003 16:51:03 +0100, "Lance" <la**********@hotmail.com> wrote:
is there a workaround for rows with null values not being returned? I am
using PHP 4.3.2 and mysql. the mysql_fetch_array just seems to ignore some
of the latest rows with null values.


Post code demonstrating the problem? Can't reproduce it here.

mysql> select * from test1;
+------+
| c |
+------+
| a |
| b |
| NULL |
+------+
3 rows in set (0.00 sec)

<pre>
<?php
$conn = mysql_connect('localhost', '*****', '********') or die('connect: ' .
mysql_error());
mysql_select_db('testdb') or die('select db: ' . mysql_error());

$res = mysql_query('select * from test1;')
or die(mysql_error());

while ($row = mysql_fetch_array($res))
var_dump($row);
?>
</pre>

Output:

array(2) {
[0]=>
string(1) "a"
["c"]=>
string(1) "a"
}
array(2) {
[0]=>
string(1) "b"
["c"]=>
string(1) "b"
}
array(2) {
[0]=>
NULL
["c"]=>
NULL
}

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.