Click here to Skip to main content
15,886,258 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: To check for updates, install an update for Windows Update Pin
OriginalGriff30-Jul-12 3:36
mveOriginalGriff30-Jul-12 3:36 
GeneralRe: To check for updates, install an update for Windows Update Pin
Eddy Vluggen30-Jul-12 3:22
professionalEddy Vluggen30-Jul-12 3:22 
GeneralBang Head! Pin
VallarasuS24-Jul-12 20:40
VallarasuS24-Jul-12 20:40 
GeneralRe: Bang Head! Pin
BillW3326-Jul-12 3:58
professionalBillW3326-Jul-12 3:58 
GeneralRe: Bang Head! Pin
Brisingr Aerowing28-Jul-12 3:30
professionalBrisingr Aerowing28-Jul-12 3:30 
GeneralRe: Bang Head! Pin
ExcellentOrg31-Jul-12 23:48
ExcellentOrg31-Jul-12 23:48 
GeneralRe: Bang Head! Pin
Brisingr Aerowing1-Aug-12 3:45
professionalBrisingr Aerowing1-Aug-12 3:45 
GeneralAnd this is why I hate PHP (again) PinPopular
Andrei Straut22-Jul-12 23:43
Andrei Straut22-Jul-12 23:43 
[begin rant]
So, I've been doing some integrations between our company Oracle E-Business Suite ERP and a website from a company that has been recently acquired by us.

Our ERP exposes a webservice that our main website and the newly acquired company's website need to call, and sync clients, orders, products, etc (the two websites are e-commerce).

So, I had to make a module for the new company website, and have that module call the ERP webservice with the needed data. The new company website is PHP. Now, I also had to output some data in some tables that would show up as a webpage full of logs, when I found a PHP bug (I guess it's a bug, cause if it's not, then it's elephanting plain weird). So let's say we have:

[outputting some unrelated table stuff]
[...].
$result .= '<td>'.date('d-m-Y g:i A', strtotime($header->getCreatedTimestamp())).'</td>';
$result .= '<td>'.(intval($header->getPlacedTimestamp() != 0)) ? 'Yes' : 'No' .'</td>'; // doing it directly screws everything up, this td and the one below are shown before the table
$result .= '<td>'.(intval($header->getPlacedTimestamp() != 0)) ? $header->getPlacedTimestamp() : '-' .'</td>';
$result .= '<td>'.$header->getSupplierName().'</td>';

[outputting other unrelated table stuff]
[...].


So, imagine my surprise when the result of the two ternaries gets placed BEFORE THE GODDAMNED TABLE!!! I mean, the output is:

[Ternaries result]
[table with my other data, no result from the two ternaries whatsoever, and the td's are simply missing]


And the fix was simply to place the ternary result into two variables, and output those (I guess those two get somehow evaluated and executed before the other code, or I just don't know):

[outputting some unrelated table stuff]
[...].$is_placed = (intval($header->getPlacedTimestamp() != 0)) ? 'Yes' : 'No';
$placed_ts = (intval($header->getPlacedTimestamp() != 0)) ? $header->getPlacedTimestamp() : '-';
$result .= '<td>'.date('d-m-Y g:i A', strtotime($header->getCreatedTimestamp())).'</td>';
$result .= '<td>'. $is_placed .'</td>'; // doing this works, the tds are shown correctly, in their places
$result .= '<td>'. $placed_ts .'</td>';
$result .= '<td>'.$header->getSupplierName().'</td>';

[outputting other unrelated table stuff]
[...].


Oh, and I also had to output the HTML table from PHP code (as a requirement, I had to follow their...'guidelines', which enforce this WTF | :WTF: )

[end rant]

Edit: Sorry, I just had to get this thing off my chest. I think I'll go shoot myself now. I miss my Android project (looking back, maybe it was simpler to just delay its completion forever, instead of ending it on time...Oh, blissful ignorance Sigh | :sigh: Sigh | :sigh: )
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.

GeneralRe: And this is why I hate PHP (again) PinPopular
BobJanova23-Jul-12 4:02
BobJanova23-Jul-12 4:02 
GeneralRe: And this is why I hate PHP (again) Pin
Andrei Straut23-Jul-12 4:25
Andrei Straut23-Jul-12 4:25 
GeneralRe: And this is why I hate PHP (again) PinPopular
W Balboos, GHB30-Jul-12 1:33
W Balboos, GHB30-Jul-12 1:33 
GeneralRe: And this is why I hate PHP (again) Pin
Andrei Straut30-Jul-12 1:57
Andrei Straut30-Jul-12 1:57 
GeneralRe: And this is why I hate PHP (again) Pin
W Balboos, GHB30-Jul-12 2:43
W Balboos, GHB30-Jul-12 2:43 
GeneralRe: And this is why I hate PHP (again) Pin
Member 885702230-Jul-12 2:12
Member 885702230-Jul-12 2:12 
GeneralRe: And this is why I hate PHP (again) Pin
Moshe Katz30-Jul-12 4:09
Moshe Katz30-Jul-12 4:09 
GeneralRe: And this is why I hate PHP (again) Pin
BobJanova30-Jul-12 2:31
BobJanova30-Jul-12 2:31 
GeneralRe: And this is why I hate PHP (again) Pin
W Balboos, GHB30-Jul-12 2:34
W Balboos, GHB30-Jul-12 2:34 
GeneralRe: And this is why I hate PHP (again) Pin
ItsTobias30-Jul-12 2:47
ItsTobias30-Jul-12 2:47 
GeneralRe: And this is why I hate PHP (again) Pin
BobJanova31-Jul-12 0:18
BobJanova31-Jul-12 0:18 
GeneralRe: And this is why I hate PHP (again) Pin
ItsTobias31-Jul-12 0:35
ItsTobias31-Jul-12 0:35 
GeneralRe: And this is why I hate PHP (again) Pin
BobJanova1-Aug-12 0:11
BobJanova1-Aug-12 0:11 
GeneralRe: And this is why I hate PHP (again) Pin
ItsTobias1-Aug-12 0:34
ItsTobias1-Aug-12 0:34 
GeneralRe: And this is why I hate PHP (again) Pin
ItsTobias30-Jul-12 2:47
ItsTobias30-Jul-12 2:47 
GeneralRe: And this is why I hate PHP (again) Pin
leif neland3-Aug-12 2:41
leif neland3-Aug-12 2:41 
GeneralRe: And this is why I hate PHP (again) Pin
BobJanova3-Aug-12 4:59
BobJanova3-Aug-12 4:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.