Jump to content

[SOLVED] $var = 'NULL' if statement problems


Greaser9780

Recommended Posts

I am trying to create a series of if statements. If the var is equal to null it should update the db. If it is not equal to null and has a value it should go to the next if statement. I have tried if ($var = 'NULL") and it always lets me write to the db even if there is a greater value there. I have tried if($var == 'NULL') and it never lets me write to the db no matter what value is in the db. I have also tried each of these with = '0' instead of null. Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/42162-solved-var-null-if-statement-problems/
Share on other sites

Here is some code:

$sql2=mysql_query("SELECT * FROM pd WHERE teamid= '$teamid'");
$res2=mysql_fetch_array($sql2);
if ($res2['pd1'] = 'NULL' ) {
$upd=mysql_query("UPDATE pd SET pd1='$playername',pos1='$pos' WHERE teamid='$teamid'");
require("pdform.php");
exit();
}

echo "BLAH";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.