Jump to content

IF statement help


jason1987

Recommended Posts

My if statement is not working the code inside is being ran everytime even when it dont meet the conditions, when i test my code with echo on the update statement its not liking lines brings up an undefined index notice for these lines

$simparent=$HTTP_POST_VARS['simparentid'];
$equtype=$HTTP_POST_VARS['equtypeid'];

 


$simparent=$HTTP_POST_VARS['simparentid'];
$equtype=$HTTP_POST_VARS['equtypeid'];

if ($simparent == !'Null')
{
if($equtype == '8' || '8')
{
 	$simins = "UPDATE itsiminfo SET simparentid=NULL WHERE itsiminfo.equid='$equid'";
 	$resultsimins = mysql_query($simins); 					// Removes link between sim card and mobile/3G - only from SIM though not via mobile or 3G
}

if($equtype == '7' || '4')
{
	$simins2 = "UPDATE itsiminfo SET simparentid=NULL WHERE simparentid='$equid'";
	$resultsimins2 = mysql_query($simins2); 				//Removes link between Mobile/3g and sim - from through mobile or 3g
}
}

Link to comment
Share on other sites

I Have changed this, but still dont appear to be working correctly ??? ???

 

$simparent=$HTTP_POST_VARS['simparentid'];
$equtype=$HTTP_POST_VARS['equtypeid'];

if ($simparent != 'Null')
{
if($equtype == '8' || '8')
{
	$simins = "UPDATE itsiminfo SET simparentid=NULL WHERE itsiminfo.equid='$equid'";
	$resultsimins = mysql_query($simins); 					// Removes link between sim card and mobile/3G - only from SIM though not via mobile or 3G
}

if($equtype == '7' || '4')
{
	$simins2 = "UPDATE itsiminfo SET simparentid=NULL WHERE simparentid='$equid'";
	$resultsimins2 = mysql_query($simins2); 				//Removes link between Mobile/3g and sim - from through mobile or 3g
}
}

Link to comment
Share on other sites

Try this instead of your code:

<?php
$simparent=$_POST['simparentid'];
$equtype=$_POST['equtypeid'];
if (strlen($_POST['simparentid']) > 0) {
     switch ($_POST['equtype']) {
              case '8':
	$q = "UPDATE itsiminfo SET simparentid=NULL WHERE itsiminfo.equid='$equid'";
	$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
              case '7':
              case '4':
	$q = "UPDATE itsiminfo SET simparentid=NULL WHERE simparentid='$equid'";
	$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
              default:
                echo 'equtype is not 8, 7, or 4 but :' . $_POST['equtype'] . '<br>';
      }
}
?>

 

Ken

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.