dflow Posted November 12, 2008 Share Posted November 12, 2008 hi im trying to filter records in a record set according to the following sql : SELECT * FROM `region_list` WHERE `RegionName` IS NOT NULL as you understand i want to get all the records that their fileds are filled with a RegionName for some reason it isnt working im testing it in my phpmyadmin interface and get no errors just the whole table with no filitering RegionName varchar(255) utf8_unicode_ci NULL No any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/ Share on other sites More sharing options...
premiso Posted November 12, 2008 Share Posted November 12, 2008 When you input a row into the table, are you distinctly setting the value to NULL, or '' because there is a difference. This may help SELECT * FROM `region_list` WHERE (`RegionName` IS NOT NULL AND `RegionName` <> '') That should check for both. Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/#findComment-688509 Share on other sites More sharing options...
dflow Posted November 12, 2008 Author Share Posted November 12, 2008 hi im setting it as null so it wont be demanded when inserting a new record Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/#findComment-688513 Share on other sites More sharing options...
dflow Posted November 12, 2008 Author Share Posted November 12, 2008 thanks works like a charm Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/#findComment-688521 Share on other sites More sharing options...
dflow Posted November 12, 2008 Author Share Posted November 12, 2008 hi again i jumped the gun: in the phpmyadmin it works aswell as in DREAMWEAVER but on the site i get a query error: Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in /home/www/mysite.com/include/region_list_footer.php on line 62 here s the code: <?php require_once('../Connections/international.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_international, $international); $query_RsRegions = "SELECT * FROM `region_list` WHERE ( `RegionName` IS NOT NULL AND `RegionName` <> '' )"; $RsRegions = mysql_query($query_RsRegions, $international) or die(mysql_error()); $row_RsRegions = mysql_fetch_assoc($RsRegions); $totalRows_RsRegions = mysql_num_rows($RsRegions); mysql_free_result($RsRegions); ?> <table width="200" border="0"> <tr> <th scope="col"><table > <tr> <?php $RsRegions_endRow = 0; $RsRegions_columns = 3; // number of columns $RsRegions_hloopRow1 = 0; // first row flag do { if($RsRegions_endRow == 0 && $RsRegions_hloopRow1++ != 0) echo "<tr>"; ?> <td><?php echo $row_RsRegions['RegionName']; ?></td> <?php $RsRegions_endRow++; if($RsRegions_endRow >= $RsRegions_columns) { ?> </tr> <?php $RsRegions_endRow = 0; } } while ($row_RsRegions = mysql_fetch_assoc($RsRegions)); if($RsRegions_endRow != 0) { while ($RsRegions_endRow < $RsRegions_columns) { echo("<td> </td>"); $RsRegions_endRow++; } echo("</tr>"); }?> </table></th> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/#findComment-688543 Share on other sites More sharing options...
premiso Posted November 12, 2008 Share Posted November 12, 2008 Your mysql_free_result($RsRegions) way too earlier, put it after the do while loop and this should work fine. Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/#findComment-688548 Share on other sites More sharing options...
dflow Posted November 13, 2008 Author Share Posted November 13, 2008 GREAT THX Quote Link to comment https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/#findComment-689191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.