Skip navigation.
Home

The magic in header.inc.php...

DB Hoopla | Wonky Code

Last week we looked at PHP's limited MySQL functionality. Today we have another example for the PHP guys to improve the MySQL library. That's sarcasm for those that missed it the first time.

On a more WTF note, I wonder what's inside header.inc.php. Especially since it is included into the code like nine times! Anybody know the difference between using include() versus require()?

Thanks to Stefan for sending this in.

<?php
include("header.inc.php");

$resultaa = mysql_query("SELECT gameid_gewinn_slot FROM `V4_gameid_gewinn`");
$myrowaa = mysql_fetch_row($resultaa);
$gameid_gewinn_slot = $myrowaa[0];

$resultab = mysql_query("SELECT gameid_gewinn_gewinn_slot FROM `V4_gameid_gewinn`");
$myrowab = mysql_fetch_row($resultab);
$gameid_gewinn_gewinn_slot = $myrowab[0];

$resultac = mysql_query("SELECT gameid_gewinn_slot_2 FROM `V4_gameid_gewinn`");
$myrowac = mysql_fetch_row($resultac);
$gameid_gewinn_slot_2 = $myrowac[0];

$resultad = mysql_query("SELECT gameid_gewinn_gewinn_slot_2 FROM `V4_gameid_gewinn`");
$myrowad = mysql_fetch_row($resultad);
$gameid_gewinn_gewinn_slot_2 = $myrowad[0];

$resultae = mysql_query("SELECT gameid_gewinn_zockie FROM `V4_gameid_gewinn`");
$myrowae = mysql_fetch_row($resultae);
$gameid_gewinn_zockie = $myrowae[0];

$resultaf = mysql_query("SELECT gameid_gewinn_gewinn_zockie FROM `V4_gameid_gewinn`");
$myrowaf = mysql_fetch_row($resultaf);
$gameid_gewinn_gewinn_zockie = $myrowaf[0];

// ... and repeat a dozen or so times.

$gameid_o = mysql_query("SELECT id FROM `V4_jackpot_o`");

require(
"header.inc.php");

while (
$myrowo = mysql_fetch_row($gameid_o)) {
$gameido = $myrowo[0];
};

$gameid_n = mysql_query("SELECT id FROM `V4_jackpot_n`");

require(
"header.inc.php");

while (
$myrown = mysql_fetch_row($gameid_n)) {
$gameidn = $myrown[0];
};

$gameid_p = mysql_query("SELECT id FROM `V4_jackpot_p`");

require(
"header.inc.php");

while (
$myrowp = mysql_fetch_row($gameid_p)) {
$gameidp = $myrowp[0];
};

$gameid_b = mysql_query("SELECT id FROM `V4_jackpot_b`");

require(
"header.inc.php");

while (
$myrowb = mysql_fetch_row($gameid_b)) {
$gameidb = $myrowb[0];
};

$gameid_m = mysql_query("SELECT id FROM `V4_jackpot_m`");

require(
"header.inc.php");

while (
$myrowm = mysql_fetch_row($gameid_m)) {
$gameidm = $myrowm[0];
};

$gameid_q = mysql_query("SELECT id FROM `V4_jackpot_q`");

require(
"header.inc.php");

while (
$myrowq = mysql_fetch_row($gameid_q)) {
$gameidq = $myrowq[0];
};

$gameid_r = mysql_query("SELECT id FROM `V4_jackpot_r`");

require(
"header.inc.php");

while (
$myrowr = mysql_fetch_row($gameid_r)) {
$gameidr = $myrowr[0];
};

$gameid_s = mysql_query("SELECT id FROM `V4_jackpot_s`");

require(
"header.inc.php");

while (
$myrows = mysql_fetch_row($gameid_s)) {
$gameids = $myrows[0];
};

// more nice stuff inside .. but not necessary for laughing :)
?>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

If include() fails, it spits

If include() fails, it spits out a warning and keeps going.  If require() fails, it spits out an error and dies.

include_once and require_once do the same thing, except each file can only be included once during execution to prevent recursive includes.

So not only do they not under

So not only do they not understand that you can fetch multiple columns from a database at one time...they choose to loop across each result set and store the first column of the final row.  Perhaps he needs to learn LIMIT and ORDER BY.  The include/require nonsense just fails all logic.

rofl german code againit can

rofl german code again
it can be usefull to include a file several times, to display some content if needed. But I have got no idea why MySQL is abused this way...GERmany rulz!!

Why not just make it a functi

Why not just make it a function and include it once and call that instead?  :P

Maybe we have more software d

Maybe we have more software developer in germany? Or maybe we have more software developer in germany, who think they are software developer but aren't? Or some of us germans have just a lack of intelligence (does anybody know PISA?)

lucky that my german code doesn't look like german code. Neither do I use german words (in my own software) nor do I (hopefully) write such damn stupid code I see here.

yes i know PISA, but I think

yes i know PISA, but I think american students are much more stupid than german. Or why doesn't america want to be tested by PISA?????
GERmany rulz!!

just look at the names of his

just look at the names of his var's:

$myrowaa ->$myrowaf

and 

$myrowo -> $myrowr

guess there are still some more but since the code is cut in pieces, WTF ?!

Hahaha... too good to be tr

Hahaha... too good to be true...

I guess that guy was complaining about how slow his code was, or even better: what a crappy server that couldn't handle some (dozens of) full table queries so he could take just the first value and discard the rest.

Post new comment




*

  • Web and e-mail addresses are automatically converted into links.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <p> <br /> <br>