if (isset($_GET['issue']) && !empty($_GET['issue'])) { switch($_GET['issue']) { case 'badurl': $errmsg = '<img src="images/warn.gif" align="absmiddle" border="0" /> The URL you entered could not be found. Please double check your link'; break; case 'noaccount': $errmsg = '<img src="images/warn.gif" align="absmiddle" border="0" /> No account could be found to complete your download. Please try again in few minutes.'; break; case 'nourl': $errmsg = '<img src="images/warn.gif" align="absmiddle" border="0" /> Either you did not enter a valid URL, or we\'re out of Accounts.'; break; case 'invalidurl': $errmsg = '<img src="images/warn.gif" align="absmiddle" border="0" /> The URL you entered was not a valid URL. Please double check your link'; break; case 'exceed': $errmsg = '<img src="images/warn.gif" align="absmiddle" border="0" /> You have exceeded the maximum downloads allowed in 24 hours.'; break; case 'serprob': $errmsg = '<img src="images/warn.gif" align="absmiddle" border="0" /> Seems to be a Server Problem. You may try downloading again.'; break; default: $errmsg = ''; } $errmsg = '<div id="box"><b>'.$errmsg.'</b></div>'; } PHP: <?php echo $errmsg; ?> PHP: These code are in index.php. And I want to show message with for example index.php?issue=nourl. << This is working fine, but if i simply browse with index.php, I got this error: Undefined variable: errmsg in XXXX on line 227
Most webservers won't output the error. Your current error display settings are configured for developers, so you should be fine when uploading. Either way, should be a simple case of declaring the variable at the start of your script. i.e. for index.php: <?php $errmsg = ''; PHP: Or you could only output if the variable has been initialized: if( isset( $errmsg ) ) echo $errmsg; PHP:
You can try code below. how about it? $errmsg = '<div id="box"><b>'; if (isset($_GET['issue']) && !empty($_GET['issue'])) { switch($_GET['issue']) { case 'badurl': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> The URL you entered could not be found. Please double check your link'; break; case 'noaccount': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> No account could be found to complete your download. Please try again in few minutes.'; break; case 'nourl': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> Either you did not enter a valid URL, or we\'re out of Accounts.'; break; case 'invalidurl': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> The URL you entered was not a valid URL. Please double check your link'; break; case 'exceed': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> You have exceeded the maximum downloads allowed in 24 hours.'; break; case 'serprob': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> Seems to be a Server Problem. You may try downloading again.'; break; default: $errmsg .= ''; } $errmsg = '</b></div>'; } PHP:
Upz... missing "." in the end of code $errmsg = '<div id="box"><b>'; if (isset($_GET['issue']) && !empty($_GET['issue'])) { switch($_GET['issue']) { case 'badurl': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> The URL you entered could not be found. Please double check your link'; break; case 'noaccount': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> No account could be found to complete your download. Please try again in few minutes.'; break; case 'nourl': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> Either you did not enter a valid URL, or we\'re out of Accounts.'; break; case 'invalidurl': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> The URL you entered was not a valid URL. Please double check your link'; break; case 'exceed': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> You have exceeded the maximum downloads allowed in 24 hours.'; break; case 'serprob': $errmsg .= '<img src="images/warn.gif" align="absmiddle" border="0" /> Seems to be a Server Problem. You may try downloading again.'; break; default: $errmsg .= ''; } } $errmsg .= '</b></div>'; PHP: