Thursday, December 4, 2008

PHP Header Redirect

Most people may already know this but for some reason I always forget the syntax (I know... its simple...).  So here is how you can redirect to a page with PHP.

Remember: You have to redirect BEFORE loading any HTML tags or header information.  This should always be tested before ANY echo/print tags or any output.

header('Location: http://www.example.com/');
exit;

Don't forget the exit, this prevents the rest of the page from loading and possibly stopping your redirect.

Tuesday, December 2, 2008

Flash Multiply Error

Flash PNG or any image Multiply Filter error.

I am having trouble with the "multiply filter" in Flash. Evidently, I am not the only one.

Someday, I hope to find an answer.


Here's a guy who posted the SAME issue:
http://www.bitsofstring.org/extra/flash/flashblendingtest.html

Saturday, November 22, 2008

FireFox scollbar ... always there?

Tired of seeing the site jump back and forth from "non-scrolling" pages to scrolling pages? Throw this in your CSS:

html {
overflow: -moz-scrollbars-vertical;
}

Now there is always a vertical scroll bar (even "grayed out") present and the site stays in position. No more kitters. No more wondering if the CSS code is correct or did something change...

Done!

Friday, November 21, 2008

IE6 margin fix

CSS and IE6 Margin Fix on float!

When floating a < div > in Internet Explorer 6 and any kind of a margin ... it doubles the amount ... of course it does. That is exactly what IE6 should do. Especially since FireFox, and all the others actually set the margin to the number specified.

This guy posted the fix... it's pretty simple. Just add "display:inline" to the CSS attribute.

http://www.positioniseverything.net/explorer/doubled-margin.html

Matt Crigger
http://www.phirebranding.com

Thursday, November 20, 2008

Escape Character in MSSQL

I had a frustrating time trying to escape single quotes in MSSQL.  I had enclosed my content in single quotes so that double quotes would be okay, but then I had to deal with if a user put a single quote in the field.  In standard MySQL you could just use the backslash (\) but MSSQL requires a single quote (') in order to escape a character!

Here is a little function I made in PHP to look for single quotes and doubling them so that they would be escaped (thus allowing the content to be inserted into MSSQL).

//********************************
// fix quotes for mssql
//********************************
function mssql_quote_fix($text)
{
$text = str_replace("'", "''", $text);
return $text;
}

Just call this function on the text you're trying to insert.

I'll give a little credit to this article for helping me: Escape Character In Microsoft SQL Server 2000

Wednesday, November 19, 2008

cURL Alternative to PHP Include (with SESSIONs)

This is followup to my previous post about cURL Alernative to PHP Include.  Basically, the method I posted before didn't copy over the current $_SESSION in PHP to the page that you were calling.  This mean, that page didn't know the session (i.e. if someone was logged in).

The following code over comes this problem and passes along PHP's $_SESSION information to the called page.  This has been tested for pages on the same server, I'm not sure how it will work if calling a page from another server.

<!-- save $_SESSION to use in call -->
session_start();
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
session_write_close();

<!-- Begin cURL call-->
$curl_handle = curl_init('enter_external_url_here');
curl_setopt( $curl_handle, CURLOPT_COOKIE, $strCookie );
curl_exec($curl_handle);
curl_close($curl_handle);

Tuesday, November 18, 2008

cURL Alternative to PHP Include

cURL is usually installed with PHP on a server.  I ran into a problem where I needed to be able to include external URLs into a website.  The server I was using didn't allow for urls in the include field (allow_url_include was off).  So, I used this bit of code to do the same thing:

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'enter_external_url_here');
curl_exec($curl_handle);
curl_close($curl_handle);

Make sure to replace enter_external_url_here with the actual URL.  Quotes are required around the URL.