2

I am new to Drupal, and I was trying a small example from Book "Pro Drupal 7 Development", this is an example of basic menu system, here is code:

function menufun_menu() {
$items['menufun'] = array(
    'title' => 'Greeting',
    'page callback' => 'menufun_hello',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
);
return $items;
}

function menufun_hello($first_name = '', $last_name = '') {
return t('Hello, @first_name @last_name',
    array('@first_name' => $first_name, '@last_name' => $last_name));
}

But I got HTTP 500 Error all the time:

The website encountered an error while retrieving 'http://example.com/SampleDrupalSite/'. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

When I tried function menufun_hello() without page callback arguments, it was all okay. Here is code without parameters:

    function menufun_hello() {
    return t('Hello!');
    }

May I ask what was wrong with this? (Plus, I've googled before I post it here).

1

Really embarrassed to say I made one tiny small mistake in this line of code:

return t('Hello, @first_name @last_name',
array('@first_name' => $first_name, '@last_name' => $last_name));

I was typing the first comma while switched to Chinese Simplified PinYin, correct code should be:

return t('Hello, @first_name @last_name',
array('@first_name' => $first_name, '@last_name' => $last_name));

After I changed it, everything is okay now. Thank you all for paying attention to my silly question.

| improve this answer | |
  • :(. what the bad – Yuseferi Sep 9 '12 at 8:13
  • :(, people like me make mistakes all the time.. – lyonsun Sep 9 '12 at 8:14
-2

500 Internal Server Error How To Fix a 500 Internal Server Error

By Tim Fisher, About.com Guide See More About:browser error messagesie problemsfirefox problemschrome problemssafari problems How You Might See the 500 Error

The 500 Internal Server Error message might be seen in any number of ways because each website is allowed to customize the message. Here are several common ways that you might see the HTTP 500 error:

"500 Internal Server Error"

"HTTP 500 - Internal Server Error"

"Internal Server Error"

"500 Error"

"HTTP Error 500" 500 Internal Server Error messages can show up in any browser in any operating system.

The 500 Internal Server Error displays inside the Internet browser window, just as web pages do.

Cause of HTTP 500 Errors

The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the web site's server but the server could not be more specific on what the exact problem is.

That's not a lot of information to go on but there are a few things you can do.

How To Fix the 500 Internal Server Error

The 500 Internal Server Error is a server-side error, meaning the problem is not with your computer or Internet connection but instead is a problem with the web site's server.

Even though the issue is not yours to fix, there are some things you can try:

Reload the web page. You can do that by clicking the refresh/reload button, pressing F5, or trying the URL from the address bar again.

Even though the 500 Internal Server Error is reporting a general error on the web site's servers and not your computer, the server error may only be temporary. Trying the page again will often be successful.

Note: If the 500 Internal Server Error message appears during the checkout process at an online merchant, be aware that duplicate attempts to checkout may end up creating multiple orders - and multiple charges! Most merchants have automatic protections from these kinds of actions but it's still something to keep in mind.

Come back later. The 500 Internal Server Error message is one of the most common HTTP error message seen when checking out during an online purchase so sales are often disrupted. This is usually a great incentive to resolve the issue very quickly.

Contact the webmaster. Chances are good that the website administrators already know about the 500 error but if you suspect they don't, you can always try to contact the website directly.

Also Be carful about how pass arguments to callback function . You returned t() function in where not form exist . hook_menu documentation
Pass arguments using hook_menu

| improve this answer | |
  • We usually return something on menu callback function so Drupal can add rest of the page. Plus, it's not a problem about t() as it seems. Didn't downvote though – AyeshK Sep 8 '12 at 19:10
  • thanks. i edit it (but I remembered in drupal 6 in callback fucntion I tried to drupal_set_message without any form ,drupal dont show me any thing , just a blank white page) – Yuseferi Sep 9 '12 at 4:51
  • I am sorry but I guess you misunderstood my question, I tried callback function menufun_hello() without arguments, and it was okay, everything worked well, but when I try callback function menufun_hello($first_name = '', $last_name = '') with parameters as $firstname and $last_name, it starts to give me Server Error HTTP 500. And then no page can be opened. Still thank you for your attention to this post. – lyonsun Sep 9 '12 at 7:19
  • I know , my answer is your are mistake call , if you want call it with parameters this is not worked. I edit my anwser – Yuseferi Sep 9 '12 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.