[PHP|MySQL] Crappy Error Handling
So, I slapped together some crap into a function and used it to catch SQL errors on one of the scripts I was working on. I still haven't decided if I want to release the script as GPL, but you can have this part of it at least. Bash it, tell me it sucks, whatever, do with it as you please.
<?php
function display_error($errortype, $sqlerror)
{
echo "<html><head><title>[SITE_TITLE] Error</title></head><body>";
echo "<div style='width:100%;height:100%;vertical-align:middle;text-align:center;'>";
echo "<div style='padding:20px;margin:20px;width:600px;height:300px;border:2px solid #000;background:#FF0000;text-align:left;'><h2><font color=white>Connection Error</font></h2><br /><br />";
echo "A fatal error occured on this page. The error type is ERROR_[" . $errortype . "]. If this was an SQL issue, the full error message will be displayed below.<br /><br />";
echo "<b>SQL_ERROR():</b><br /><br />";
echo $sqlerror;
echo "</div></div></body></html>";
}
// Load internal functions
//require_once("includes/functions.inc");
// Connect to database (quietly)
$bool_sqlconnect = @mysql_connect($site['sql']['hostname'],$site['sql']['username'],$site['sql']['password']);
$bool_sqldbase = @mysql_select_db($site['sql']['database']);
// On connection failure, display the problem.
if(!$bool_sqlconnect) { display_error("sqlconnect", mysql_error()); die; }
if(!$bool_sqldbase) { display_error("sqldbase", mysql_error()); die; }
?>
Enjoy.
fuegoCMS
Work sortof continues on IWM's fuegoCMS, a former BFN Project based in PHP and MySQL.
fuegoCMS is a Dynamic Content Management System designed for low-cost, low-footprint implementations. fCMS currently requires a working installation of some webserver, PHP, and MySQL to function. It is currently at Beta v1.0 Stage, following a complete rewrite of the old code.
As of right now it is still undecided whether this will be a closed-source or an open-source project, and is remaining closed-source for the moment. You may be able to catch some of the trickier functions posted on Bytes of Interest.
More to come (maybe) when i get around to it (possibly) and do some work (definately not).
February 27, 2005: 7:19 PM
So, I can add posts with the admin section now. and delete them. I guess I'll sorta be continuously updating this shit until I get it done. Should be interesting, I guess. Right now, the post entry is strictly HTML, i may work in something with FCKEdit later so I don't have to use tags; either that or do like, message parsing and convert bbcode-style tags to html. dunno. An improvement for the final product, I guess. As for the whole Drama bashing I had on earlier, forget that. I worked out all my anger typing that. :/ Another thing to add to this later, maybe; allowing images inline with the posts, rather than just the image section. Dunno. Might be overkill. So, I have a 6 page essay due tomorrow, and i have: 4 lines done. :/ I also have a physics project due next week that I haven't started. SAT's at bburg on May 7, if anyone wants to join me. As for the various projects going on here at binaryfire, one has been preliminarily completed. The Winely Photography website [link] is more or less done; this meaning that the site is working order, but I still have a few minor details to work out. Aka, fixing the image upload thumbnail resize function, a few cosmetic details, etc. Another project is automating this script, bomb();. This script will be replacing our free hosting level, a blogging type script. Another project is the Phillp Powers website [link], which is almost complete; needing only to fix the update function. This summer, there will be a 3 day workshop on Structual Web Programming Methods with PHP and HTML. This workshop is mandatory for the web development team, but anyone is free to attend. If you plan on attending, please email wordenj@binaryfire.net with "Summer Workshop 2005" in the subject line. An exact date for this workshop will be published later on. To all binaryfire staff members: There will be a meeting on Saturday, March 19th at noon. So, I guess I'm off to start that English essay. Maybe. <3 Katie!
January 3, 2005: 10:23PM
playing: Evanescence - My Last Breath
So, I guess I've settled back into the scheme of things back at school. As much as i despise said scheme. -_- Hi Katie! And Erin! Seemingly, i have put off all of my homework until...now. Great. I spent today working on dynamicanizing a website forĀ Phillip Powers, and playing some of the games on my blog. AND OH MY GOD! I FOUND WHAT I'VE BEEN MISSING RECENTLY!LEMMINGS! And Combat Flight Simulator. Anyone have a copy of these? I wanna play. :/
PHP. Ugh, I hate the shit. But it's one of those nessicary evils.PHP is the language i am the most fluent in, and yet the one i hate the most. Perhaps it is my fluency in it that fuels my hatred for it. Seemingly, a vicious circle. All my work gets done behind the scenes. If only you people knew how much work goes into making these websites work....aye. Back to the dreaming wessel. Beam me out, Scotty!
<3 Katie!
