In $i = 0, is 0 the same as nothing or does it count as 1?
In a form I have these two fields - file and file_new. Only one (hopefully) should contain a value. I have to determine which one has a value to determine which function to execute.
[PHP]$file = mysql_real_esca pe_string($_POS T['file']);
$file_new = mysql_real_esca pe_string($_POS T['file_new']);
$i = 0;
if ($file > $i AND $file_new < $i)
{
function file();
}
else
{
funtion file_new();
}[/PHP]
I guess I could just leave off the second part of the if statement, unless this would help me to make sure that only one variable contains a value. If file_new also contained a value I could return an error message saying that only one of these fields can be filled out on the form.
Will this work or no?
OR is this better: [PHP]
if ($file != '' AND $file_new == '') {
run this code
}
if ($file == '' AND $file_new != '') {
run this code
}
if ($file != '' AND $file_new != '') {
run this code
}
[/PHP]
Thanks.
In a form I have these two fields - file and file_new. Only one (hopefully) should contain a value. I have to determine which one has a value to determine which function to execute.
[PHP]$file = mysql_real_esca pe_string($_POS T['file']);
$file_new = mysql_real_esca pe_string($_POS T['file_new']);
$i = 0;
if ($file > $i AND $file_new < $i)
{
function file();
}
else
{
funtion file_new();
}[/PHP]
I guess I could just leave off the second part of the if statement, unless this would help me to make sure that only one variable contains a value. If file_new also contained a value I could return an error message saying that only one of these fields can be filled out on the form.
Will this work or no?
OR is this better: [PHP]
if ($file != '' AND $file_new == '') {
run this code
}
if ($file == '' AND $file_new != '') {
run this code
}
if ($file != '' AND $file_new != '') {
run this code
}
[/PHP]
Thanks.
Comment