Page 1 of 1
if else statement gets ignored?
Posted: Wed Mar 28, 2007 6:17 pm
by FluxNYC
Hey so basically im making a script to re-order a list the catch is there are multiple lists in this case banner and item. To determine what list is later hit it checks for the type. Now when i pass the variable banner for TYPE and do the echos the first echo that comes out is "side_banners" but then once it gets to the second echo the table is suddenly "items". Any ideas?
Code: Select all
$type_new = $_REQUEST[type];
if($type_new=="banner")
{
$table = $banners_table;
$column = "side_banner_id";
echo "banner sayas this is $table ..";
}
elseif($type_new=="item");
{
$table = $items_table;
$column = "item_id";
}
if($_REQUEST[move] == "up")
{
echo "After the table is $table";
}
Posted: Wed Mar 28, 2007 6:22 pm
by volka

still using _REQUEST[type] instead of _REQUEST['type'], probably means you're not using error_reporting=E_ALL either.
try
Code: Select all
error_reporting(E_ALL);
ini_set('display_errors', true);
switch($_REQUEST['type']) {
case 'banner':
$table = $banners_table;
$column = "side_banner_id";
echo "banner sayas this is $table ..";
break;
case 'item':
$table = $items_table;
$column = "item_id";
echo "banner sayas this is $table ..";
break;
default:
echo "unknown _REQUEST[type]: ", $_REQUEST['type'];
break;
}
feedback would be nice.
Posted: Wed Mar 28, 2007 7:19 pm
by FluxNYC
Hey. Using a case solved it but there no errors after ptuting in the appropriate 's. still find it weird an ifelse statement didnt work...thanks though

Posted: Wed Mar 28, 2007 7:58 pm
by Elias
Code: Select all
$type_new = $_REQUEST[type];
if($type_new=="banner")
{
$table = $banners_table;
$column = "side_banner_id";
echo "banner sayas this is $table ..";
}
elseif($type_new=="item");
{
$table = $items_table;
$column = "item_id";
}
if($_REQUEST[move] == "up")
{
echo "After the table is $table";
}
Could of also done it like this:
Code: Select all
$type_new = $_REQUEST[type];
if($type_new=="banner")
{
$table = $banners_table;
$column = "side_banner_id";
echo "banner sayas this is $table ..";
}
elseif($type_new=="item");
{
$table = $items_table;
$column = "item_id";
}
if($_REQUEST[move] == "up")
{
echo "After the table is $table";
} else {
code:
Please correct me if i am wrong. I am still learning

Posted: Wed Mar 28, 2007 8:13 pm
by Begby
FluxNYC wrote:Hey. Using a case solved it but there no errors after ptuting in the appropriate 's. still find it weird an ifelse statement didnt work...thanks though

As Volka has pointed out to you in multiple posts
- Start quoting things right
- Turn on error reporting following his examples
- Start using mysql_error as per his examples
These things will help make it more obvious what the problem is when things fail.
Posted: Wed Mar 28, 2007 10:07 pm
by RobertGonzalez
Just a follow up to the advice you are getting on error reporting and error checking...
Only do this on your local development environment. DO NOT LEAVE DISPLAY ERRORS ON IN PRODUCTION. Now that this is clarified, you can carry on
