This topic is locked

BeforeDelete, Checking null variables and interst to another table

12/15/2009 3:29:36 AM
PHPRunner General questions
A
afa1999 author

Hi,

I want to insert a record to another table by checking null variables, it is checking but not adding.

Here is the code
Table1

id, name, indate, outdate

table2

id, name, indate, outdate
global $conn,$strTableName;

if($deleted_values["indate"] == '')

{echo ("<script>alert('You cannot delete!')</script>");

return false;

}

else

if($deleted_values["outdate"] == '')

{echo ("<script>alert('You cannot delete!')</script>");

return false;
}

else

$strSQLSave = "INSERT INTO table2 (id, name, indate, outdate) SELECT id, name, indate, outdate FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);

return true;

J
Jane 12/15/2009

Please see my changes below:

global $conn,$strTableName;

if(!$deleted_values["indate"])

{

echo ("<script>alert('You cannot delete!')</script>");

return false;

}

elseif(!$deleted_values["outdate"])

{

echo ("<script>alert('You cannot delete!')</script>");

return false;

}

else

{

$strSQLSave = "INSERT INTO table2 (id, name, indate, outdate) SELECT id, name, indate, outdate FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);

return true;

}
A
afa1999 author 12/16/2009



Please see my changes below:

global $conn,$strTableName;

if(!$deleted_values["indate"])

{

echo ("<script>alert('You cannot delete!')</script>");

return false;

}

elseif(!$deleted_values["outdate"])

{

echo ("<script>alert('You cannot delete!')</script>");

return false;

}

else

{

$strSQLSave = "INSERT INTO table2 (id, name, indate, outdate) SELECT id, name, indate, outdate FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);

return true;

}




Hi, if i do like this way, code doesnt check the empty=null areas but if i change code like this if(!$deleted_values["indate"] ==''), it works for 'indate' but not for outdate.

I just want to check these 2 areas indate and outdate. If they are null i dont want to allow to delete, if they are not null i want to allow to delete and insert that data to another table.

Any suggestion?

Thanks for your help.

J
Jane 12/16/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.