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
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";

Link to comment
Share on other sites

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.