Re: [PHP] (Drupal function) getting error : "notice : Undefined index ?"

2003-08-25 Thread Curt Zirzow
* Thus wrote fatih olcer ([EMAIL PROTECTED]):
> hi,
> 
> 
> i think i have a configuration problem. but i couldn't find any
> solution. i can run the same code without any problems on win98 (phpdev5
> installed)
> i have changed some php.ini settings like display_errors = off 
> but still getting errors.

IMO, turning errors of is a bad thing, a program should run
smoothly without errors.  Although with 3rd party packages
sometimes this is hard to avoid.

> 
> 
> - what causes "Undefined index" error?

An undefined index error is caused when accessing an index that
doesnt exist, so if you have an array as follows:
  $var = array('index1' => 'value');

And you try to access:
  echo $var['index2'];

The error will get displayed.

> - what is the problem on "function node_page()" (see below) ?

Sorry unable to help you with this.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] (Drupal function) getting error : "notice : Undefined index ?"

2003-08-25 Thread fatih olcer
hi,


i have installed drupal 4.2.0 without any problems. but when i try to
connect to
my local webserver i get errors: "notice : Undefined index"
i couldnt  get any reply to my messages from drupal.com.

i think i have a configuration problem. but i couldn't find any
solution. i can run the same code without any problems on win98 (phpdev5
installed)
i have changed some php.ini settings like display_errors = off 
but still getting errors.


- what causes "Undefined index" error?
- what is the problem on "function node_page()" (see below) ?

i'm php newbie.  thanks for help.

op. system  :  RH9 (with apache,php on it)
drupal version :  4.2.0

thanks .
Fatih Olcer.


// here is a sample code to generate the error:
function node_page() {
global $id, $user, $or, $and;

 $op = $_POST["op"]; //error line error line  error line error line  error
line
 $edit = $_POST["edit"];

 if (user_access("access content")) {
   if (empty($op)) {
 $op = arg(1);
   }

   if ($op == "feed") {
 node_feed();
 return;
   }

   if ($op == "view") {
 $node = node_load(array("nid" => arg(2), "status" => 1),
$_GET["revision"]);
   }

   theme("header", $node->title);

   $name = module_invoke(arg(2), "node", "name");

   switch ($op) {
 case "add":
   theme("box", t("Submit $name"), node_add(arg(2)));
   break;
 case "edit":
   theme("box", t("Edit $name"), node_edit(arg(2)));
   break;
 case "view":
   print node_show($node, arg(3));
   break;
 case t("Preview"):
   $edit = node_validate($edit, $error);
   theme("box", t("Preview $name"), node_preview($edit, $error));
   break;
 case t("Submit"):
   theme("box", t("Submit $name"), node_submit($edit));
   break;
 case t("Delete"):
   theme("box", t("Delete $name"), node_delete($edit));
   break;
 default:
   $result = pager_query("SELECT nid, type FROM {node} WHERE
promote = '1' AND status = '1' ORDER BY static DESC, created DESC",
variable_get("default_nodes_main", 10));

   while ($node = db_fetch_object($result)) {
 node_view(node_load(array("nid" => $node->nid, "type" =>
$node->type)), 1);
   }
   print pager_display(NULL, variable_get("default_nodes_main",
10));
   }

   theme("footer");
 }
 else {
   theme("header");
   theme("box", t("Access denied"), message_access());
   theme("footer");
 }

}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php