sford999 Posted September 24, 2006 Share Posted September 24, 2006 Hi,I`m trying to make a custom mysql_error function, but its just showing the page footer instead of the header and error, and its only emailing me the file that the error occured on, no other information.This is an example of the queries[code]$result = mysql_query($sql) or die(sql_error());[/code]and this is sql_error()[code]<?phpfunction sql_error($error = ''){ make_header($head_title = 'There has been a system error'); echo "<table width=\"100%\" border=\"0\"> <tr> <td class=\"thddr3\">There has been an error. This is the error message:</td> </tr> <tr> <td class=\"thddr3\"><strong>". mysql_error() ."</strong></td> </tr> <tr> <td class=\"thddr2\">An email has been sent to the sites administrator with the full details of the error.</td> </tr></table>"; $to = 'name@domain.com'; $subject = 'MySQL error email notification'; $message = 'There has been an MySQL Error.\n The error is '. mysql_error().'\n Referrer ='.$_SERVER['HTTP_REFERER'].' \n Browser = '.$_SERVER['HTTP_USER_AGENT'].' \n IP Address = '.$_SERVER['REMOTE_ADDR'].' \n The page = '.$_SERVER['PHP_SELF']; $headers = 'From: name@domain.com' . "\r\n" .'Reply-To: name@domain.com' . "\r\n" .'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); make_footer();}?>[/code]Also I`m using this for the query strings[code]<?phpif(isset($_GET['p'])) { $p = $_GET['p']; } if(isset($_POST['p'])) { $p = $_POST['p']; }if($p == "") { $p = "index"; }if($p == "page1"){ make_header($head_title = 'page1'); include("inc/page1.php"); make_footer();}elseif($p == "page2"){ make_header($head_title = 'page2'); include("inc/page2.php"); make_footer();}else { make_header($head_title = 'page1'); include("inc/page1.php"); make_footer();}?>[/code]But if someone enters say index.php?p=4538583 then the page shows up blank, with the above code, shouldn`t it show "page1" instead of it being blank?Any help on the above would be appreciated.Thanks Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 25, 2006 Share Posted September 25, 2006 Regarding the first issueCheck the source code, see what you can seeAnd for the second issueUse Switch, not if Something like this[code]<?php$p = isset($_GET["p"]) ? $_GET["p"] : $_POST["p"];switch($p){ case "page2": make_header("page2"); include("inc/page2"); make_footer(); break; default: make_header("page1"); include("inc/page1.php"); make_footer(); break;}?>[/code]OR[code]<?php$p = isset($_GET["p"]) ? $_GET["p"] : $_POST["p"];if($p == "page2"){ make_header("page2"); include("inc/page2"); make_footer();}else{ make_header("page1"); include("inc/page1.php"); make_footer(); }?>[/code]BUTonly use the IF statement if you have 2 optionsMOre than 2 options, use Switch Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.