And it gives “Undefined index” notice on line 15. The title in the title tag works fine but the title in the body doesn’t show up. I have created similar page templates many times but never came cross this. Am I missing something?
I added that line, it displays $type array elements at the top of the page but type_title does not show up in the body where I echo it. Still the same notice.
When I add this once more:
$type = get_type($_GET[‘type’]);
just above this:
echo ‘<h1>’.$type[‘type_title_long’].‘</h1>’;
The function get_type returns type_name and type_title from the type you provided. If the type is not in the database it would return NULL value, and so you get the Undefined index notice. Make sure you provide a valid Get type when calling the script; if the value is not given, use a default value.
Ok, I solved it. The problem was that I have another included file sidebar.php before this line “$type = get_type($_GET[‘type’]);” in the body. The sidebar.php also has $type as a variable and it stores types in an array. I changed the name of that variable and now all works fine as it should. Learned another thing today:
Same variable names in included files will conflict.