Ok.. I have a SQL database with a partially filled out table. I am writing an If statement to show the result only if the variable or result is true. I am pulling my hair out because when I put in a result that is NULL, it still thinks its true.
Code:
$id = $_GET['id'];
$b = "SELECT * FROM mydatabase WHERE id = '$id'";
$b_query = mssql_query($b, $connect) or die(mssql_error());
$bp3=mssql_result($b_query,0,"picture3");
<?php if ($bp3) { ?>
<img src="../uploads/<?php echo $bp3; ?>">
<?php } ?>
---------------------------
Now, i know for a fact that bp3 = nothing. When I put another entry in place of picture3 (sus_misc), it actually works! But any of the "picture" fields seem to not work. I also have this same statement for at least 8 other table entries which all work fine as well.
All of the rows generally have the same data type and allow nulls.
If I type it *** if ($bp == false) it works.. so for some reason it thinks there is something there.. and I dont know why.
Question
Volatile
Ok.. I have a SQL database with a partially filled out table. I am writing an If statement to show the result only if the variable or result is true. I am pulling my hair out because when I put in a result that is NULL, it still thinks its true.
Code:
$id = $_GET['id'];
$b = "SELECT * FROM mydatabase WHERE id = '$id'";
$b_query = mssql_query($b, $connect) or die(mssql_error());
$bp3=mssql_result($b_query,0,"picture3");
<?php if ($bp3) { ?>
<img src="../uploads/<?php echo $bp3; ?>">
<?php } ?>
---------------------------
Now, i know for a fact that bp3 = nothing. When I put another entry in place of picture3 (sus_misc), it actually works! But any of the "picture" fields seem to not work. I also have this same statement for at least 8 other table entries which all work fine as well.
All of the rows generally have the same data type and allow nulls.
If I type it *** if ($bp == false) it works.. so for some reason it thinks there is something there.. and I dont know why.
Any ideas?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts