Marc Blase

PHP Sessions

Now I’m not sure this is due to the short comings of my coding skills or what. But I’ve found it necessary to re-declare session variables before including them in a MySQL INSERT statement.

Here’s the (il)logic:

$_SESSION["mysessionarray"] = arrary();

Push all $_POST variables, or what-have-you, into the array. Then prior to your INSERT statement:

$myvar = $_SESSION["mysessionarray"]["myvar"];

Use your new $myvar in your MySQL INSERT

EDIT: Um, rookie mistake 101. Should’ve just escaped the quotes in the $_SESSION vars. My bad.

Published on February 28, 2011

Page shadow with CSS

This handy technique will add a shadow to the top of your page:

/* top shadow */  
body:before {  
    content: ""; 
    position: fixed; 
    top: -10px; 
    left: 0; 
    width: 100%; 
    height: 10px;  
    -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8); 
    -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8); 
    box-shadow: 0px 0px 10px rgba(0,0,0,.8);  
    z-index: 100; 
}

CSS from genelocklin.

Published on February 15, 2011

Parts is Parts

In case you didn’t know what to call that part on your bicycle, this should help.

Graphic designed by Aaron Kuehn

Published on February 9, 2011

Open new browser window/tab with jQuery

Forget adding the standards non-compliant target="_blank" to your markup. Open new windows with jQuery:

$('a[rel^="external"],a[rel$="external"]').attr({target:"_blank"});
Published on February 9, 2011

overflow:hidden for neat text blocks

If you have a floated image or block that text will run into but you don’t want the text to run under the image or block. Simply apply overflow:hidden; to the css for the floated image or block.

UPDATE: This only applies to blocks that are adjacent to the floated element. If you have additional blocks that should also align with those adjacent to the float, nest them all in a div.

Published on December 13, 2010

Adding fonts to the web

Finally, and without javascript do we now have the ability to add our fonts to the web using @font-face. It’s all done with these two declarations in our CSS files:

@font-face{
font-family:'Our-Font-Name';
src: url('path/to/our/font.otf') format('opentype');
}

p {
font-family:'Our-Font-Name', georgia, serif;
}

This article contains all of the necessary info to make it work via CSS3. The article also includes instructions for some low-level hacking so fonts are also visible in the bane of the internet – IE.

And you can go ahead and skip the WEFT install and conversion with this handy tool for TTF to EFT conversion.

UPDATE: To get fonts to really work on the web, in all browsers, on all platforms I’ve decided to go with TypeKit. There is some bandwidth overhead and some minor bloat to your <head> tag but the end result is worth it.

Published on October 8, 2010

It’s getting bad.

I was just reading a forum about standards compliant new window methods and a poster had this as their signature:

<?php
$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
?>

It made me giggle. Things are getting bad around here.

Published on July 28, 2010

CSS Clearfix Hack – New Method

When a parent div has floated children div containers, apply clearfix class to parent container so the children floats are cleared and the parent container’s height is correct.

/* new clearfix */
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */

New clearfix method thanks to Perishable Press.

Published on July 26, 2010

UAR 2010

I competed in the Urban Assault Ride this last weekend with my friend Chris. It was the first time to do it for both of us, and we didn’t do too bad. Here are the results:
Male Class: 36
Overall: 77
Bib Num: 330
Team Name: Repetition Sucks Sucks
Time: 2:22:06.6

My team mate Chris. Photo by David Weaver

Published on June 28, 2010

Hope = Bicycles

A few quotes that I’ve had sitting around that I thought were worth sharing.

“When the spirits are low, when the day appears dark, when work becomes monotonous, when hope hardly seems worth having, just mount a bicycle and go out for a spin down the road, without thought on anything but the ride you are taking.”
– Sir Arthur Conan Doyle

“When I see an adult on a bicycle, I do not despair for the hope of the human race.”
– H.G. Wells

Go ride a bike.

Published on June 24, 2010