Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/132427-is-not-null-not-filtering/
Share on other sites

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.

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.