Monday, December 22, 2008
Making a Link Select a Select Box in Javascript
Tuesday, December 16, 2008
Server Root Path with PHP
Friday, December 5, 2008
Trim Whitespace in PHP
Description
This function returns a string with whitespace stripped from the beginning and end of str . Without the second parameter, trim() will strip these characters:
- " " (ASCII 32 (0x20)), an ordinary space.
- "\t" (ASCII 9 (0x09)), a tab.
- "\n" (ASCII 10 (0x0A)), a new line (line feed).
- "\r" (ASCII 13 (0x0D)), a carriage return.
- "\0" (ASCII 0 (0x00)), the NUL-byte.
- "\x0B" (ASCII 11 (0x0B)), a vertical tab.
Returning Content to PHP Variable with cURL
Thursday, December 4, 2008
PHP Header Redirect
header('Location: http://www.example.com/');
exit;
Tuesday, December 2, 2008
Flash Multiply 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?
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
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
Wednesday, November 19, 2008
cURL Alternative to PHP Include (with SESSIONs)
Tuesday, November 18, 2008
cURL Alternative to PHP Include
Friday, November 14, 2008
Simple Javascript Object Check
Thursday, November 13, 2008
When Tables are Okay
Tuesday, November 11, 2008
EM Conversions for Base Font of 12px
Base (from browser): 16px;Body (CSS): 75% (12px);
Sizing Text with EMs
- The default font-size at 'medium' on regular browsers is 16px
- EMs are dependant on their parent element's size
- Default browser size: 16px
- Intended font-size: 12px
- Value in EMs: 12/16 = .75em
Thursday, November 6, 2008
CSS Cheat Sheet
Simple form confirmation
Friday, October 31, 2008
SQL Random Rows
Select a random row with MySQL:
SELECT column FROM table ORDER BY RAND() LIMIT 1
Select a random row with PostgreSQL:
SELECT column FROM table ORDER BY RANDOM() LIMIT 1
Select a random row with Microsoft SQL Server:
SELECT TOP 1 column FROM table ORDER BY NEWID()
Thanks to: http://www.petefreitag.com/item/466.cfm
Monday, October 27, 2008
MySQL DATETIME and PHP
Monday, October 13, 2008
SEO: mod_rewrite and dynamic pages
Thursday, October 9, 2008
SQL JOIN References
I had a previous post about LEFT JOINS but I believe w3schools does a better job at explaining them.
Wednesday, October 8, 2008
Background:none doesn't work (in IE)
<ul id="mainNav" style="">
<li style="" class="group1"><a href="#" onmousedown="showhide('mainSubGroup1')">Energy & Resource Management</a>
<ul id="mainSubGroup1">
<li id="s-t01"><a href="#" style="">Environmental Stewardship</a></li>
<li id="s-t02"><a href="/energy/index.php" style="">Climate Savers Computing Initiative</a></li>
<li id="s-t03"><a href="#" style="">Parking and Transportation Services</a></li>
<li id="s-t04"><a href="#" style="">Utilities and Plant Engineering</a></li>
</ul>
</li>
IF there is a background of some sort on the first <li> item, the items in the next level will use them as well. Adding "background:none;" does not work. Must replace with something.
Tuesday, October 7, 2008
Default Firefox Style Sheet
Monday, September 29, 2008
MySQL Count Distinct
SELECT COUNT(DISTINCT results) FROM student;
Thursday, September 25, 2008
Flash ASCII Code
Friday, September 12, 2008
IIS7 Custom Error Pages & Debug Information
Thursday, September 4, 2008
PHP Cheat Sheet
SEO: Stopping Search Engine Indexing
Wednesday, September 3, 2008
Search button and field alignmnet
#email {
margin: 0px 2px;
width: 110px;
_width: 110px;
padding: 2px 2px 0 2px;
_padding-right: 18px;
height: 16px;
_height: 16px;
background-color: #FFF;
border: 1px solid #afa9a6;
-moz-box-sizing: content-box;
float:left;
font-size:10px;
}
.search { background-image:url(/images/layout/speedclub_signup.gif); }
button.icon-replace {
-moz-outline: none;
padding: 0;
border-style: none;
background-color: transparent;
background-repeat: no-repeat;
background-position: center center;
margin:0;
}
.icon-replace {
background-repeat: no-repeat;
background-position: center center;
display: inline;
display: inline-block;
display: -moz-inline-box;
_display: inline;
zoom: 100%;
width: 44px;
padding: 0 !important;
overflow: hidden;
white-space: nowrap;
text-align: left;
word-spacing: -2ex;
letter-spacing: -2ex;
min-height: 20px;
_height: 20px;
color: transparent !important;
_font: 1px/0 monospace;
_word-spacing: -2px;
_letter-spacing: -2px;
}
WITHIN HTML
<input name="email" id="email" class="speedclub_input" type="text">
<button type="submit" id="search-submit" class="icon-replace search"><span style="display: none;">Search</span></button>
MSSQL Count Query
The count query is very useful in SQL. Below is the syntax:
SELECT COUNT(thefield) AS outputvariable FROM tablename GROUP BY thefield HAVING anyfield = yourvalue
- thefield is what you want to count
- outputvariable is what you want the count to be saved in
- tablename is the name of the table to look into
- anyfield is any field you want to use as a criteria
- yourvalue is the value for your criteria
This may also work the same for MYSQL.
Friday, August 29, 2008
MSSQL Data Types
Below is a table that gives a brief description of each of these data types.
Data Types | Description |
---|---|
bigint | Integer data from -2^63 through 2^63-1 |
int | Integer data from -2^31 through 2^31 - 1 |
smallint | Integer data from -2^15 through 2^15 - 1 |
tinyint | Integer data from 0 through 255 |
bit | Integer data with either a 1 or 0 value |
decimal | Fixed precision and scale numeric data from -10^38 +1 through 10^38 -1 |
numeric | Fixed precision and scale numeric data from -10^38 +1 through 10^38 -1 |
money | Monetary data values from -2^63 through 2^63 - 1 |
smallmoney | Monetary data values from -214,748.3648 through +214,748.3647 |
float | Floating precision number data from -1.79E + 308 through 1.79E + 308 |
real | Floating precision number data from -3.40E + 38 through 3.40E + 38 |
datetime | Date and time data from January 1, 1753, through December 31, 9999, with an accuracy of 3.33 milliseconds |
smalldatetime | Date and time data from January 1, 1900, through June 6, 2079, with an accuracy of one minute |
char | Fixed-length character data with a maximum length of 8,000 characters |
varchar | Variable-length data with a maximum of 8,000 characters |
text | Variable-length data with a maximum length of 2^31 - 1 characters |
nchar | Fixed-length Unicode data with a maximum length of 4,000 characters |
nvarchar | Variable-length Unicode data with a maximum length of 4,000 characters |
ntext | Variable-length Unicode data with a maximum length of 2^30 - 1 characters |
binary | Fixed-length binary data with a maximum length of 8,000 bytes |
varbinary | Variable-length binary data with a maximum length of 8,000 bytes |
image | Variable-length binary data with a maximum length of 2^31 - 1 bytes |
cursor | A reference to a cursor |
sql_variant | A data type that stores values of various data types, except text, ntext, timestamp, and sql_variant |
table | A special data type used to store a result set for later processing |
timestamp | A database-wide unique number that gets updated every time a row gets updated |
uniqueidentifier | A globally unique identifier |
The table was taken from: http://www.databasejournal.com/features/mssql/article.php/2212141
ASP Directory Listing
Here was my reference for this: http://www.brainjar.com/asp/dirlist/
I modified what they had to exclude files so that the user would only get the files I wanted them to see. Putting this information in a dropdown list can be very useful, but you could also list it out if you wanted.
ASP RecordSet Reference
Here's a reference for you all: http://www.itechies.net/tutorials/asp/index.phpindex-pid-rec.htm
Date & Time Formats in ASP and MSSQL
Here is a reference for formats supported in MSSQL for the datetime field. The article also gives an explanation of the difference between DATETIME and SMALLDATETIME.
http://www.databasejournal.com/features/mssql/article.php/2191631
Displaying Large Text with PHP/ASP from SQL
I found online an explanation for ASP:
I also found something similar related to PHP. My solution in both cases was as stated above, to reduce the limit for the field to something that the server-side languages could deal with. This was the case with both PHP and ASP along with both MySQL and MSSQL.After some testing I found there are no SQL Server 2005 data types
that can be read by an ASP page that hold more than 8000 characters. I
speculate that the 2-byte field length indicator is not read by ASP.
Maybe the field length of the old Access memo data type was encoded
differently. - kirkatsfw-ga
Thursday, August 28, 2008
ASP Functions List
I found a nice list of functions in ASP.
Here it is: http://www.haneng.com/FunctionSearch.asp?s=a
Wednesday, August 27, 2008
ASP & MSSQL Query Examples
Setup the Connection
'Setup the connection
Dim aConnectionString
aConnectionString = "Driver={SQL Native Client};Server=sitename\sqlexpress;Database=databasename;Uid=username;Pwd=password;"
'Connect to DB
Dim conn, R, SQL, RecsAffected
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeReadWrite
conn.ConnectionString = aConnectionString
conn.Open
Setup RecordSet & List all Entries
'select a record set
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * from table", conn
do until rs.EOF
for each x in rs.Fields
response.write(x.name)
response.write(" = ")
response.write(x.value)
next
rs.MoveNext
loop
rs.close
Select an Entry & See if it Exists
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * FROM tablename WHERE fieldname = 'fieldvalue'", conn
'check if login worked
dim found
if rs.BOF and rs.EOF then
'no entry found
found = false
else
'entry found
found = true
end if
Add an Entry
'add an entry
'conn.Execute "INSERT INTO tablename (fieldnames) VALUES (fieldvalues)"
Delete an Entry
'delete an entry
'conn.Execute "DELETE FROM tablename WHERE fieldname = 'fieldvalue'"
Update an entry
'update an entry
'conn.Execute "UPDATE tablename SET fieldname = 'somevalue' WHERE fieldname = 'fieldvalue'"
There's a lot more but these are some for reference purposes.
Resource for Connection Strings
Here is a great site for connection strings: http://www.connectionstrings.com/
Friday, August 22, 2008
Removing Line Breaks with Dreamweaver
So I searched online and found out how to remove them with Dreamweaver. Its pretty cool. This is the process:
- Open a document,
- Click inside Code View,
- Create an empty line,
- Left-click in the margin on the left hand-side of that empty line (it should turn black on Windows, blue on Mac),
- Select Menu > Edit > Find and Replace (keyboard shortcut: Ctrl + F),
- Select an option in the "Find in:" dropdown box,
- Select "Replace All" and you're done.
The source of this was here: http://www.tjkdesign.com/articles/whitespace.asp
Really really helpful! I'm sure I'll use it again.
Javascript Event Handlers
I wanted a quick list of event handlers so here they are. This is courtesy of our friends at the w3schools.
FF: Firefox, N: Netscape, IE: Internet Explorer
Attribute | The event occurs when... | FF | N | IE |
onabort | Loading of an image is interrupted | 1 | 3 | 4 |
onblur | An element loses focus | 1 | 2 | 3 |
onchange | The user changes the content of a field | 1 | 2 | 3 |
onclick | Mouse clicks an object | 1 | 2 | 3 |
ondblclick | Mouse double-clicks an object | 1 | 4 | 4 |
onerror | An error occurs when loading a document or an image | 1 | 3 | 4 |
onfocus | An element gets focus | 1 | 2 | 3 |
onkeydown | A keyboard key is pressed | 1 | 4 | 3 |
onkeypress | A keyboard key is pressed or held down | 1 | 4 | 3 |
onkeyup | A keyboard key is released | 1 | 4 | 3 |
onload | A page or an image is finished loading | 1 | 2 | 3 |
onmousedown | A mouse button is pressed | 1 | 4 | 4 |
onmousemove | The mouse is moved | 1 | 6 | 3 |
onmouseout | The mouse is moved off an element | 1 | 4 | 4 |
onmouseover | The mouse is moved over an element | 1 | 2 | 3 |
onmouseup | A mouse button is released | 1 | 4 | 4 |
onreset | The reset button is clicked | 1 | 3 | 4 |
onresize | A window or frame is resized | 1 | 4 | 4 |
onselect | Text is selected | 1 | 2 | 3 |
onsubmit | The submit button is clicked | 1 | 2 | 3 |
onunload | The user exits the page | 1 | 2 | 3 |
Listing can be found here: http://www.w3schools.com/jsref/jsref_events.asp
CSS Lists
This is a good reference if you'd like to Tame CSS Lists: http://www.alistapart.com/articles/taminglists/
Today you can do a lot with lists because you can make them look like whatever you want. So they are an ideal choice for navigation menus, lists of information, or whatever creative ideas you might have.
Thursday, August 21, 2008
MYSQL Left Join & More
http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php
Wednesday, August 20, 2008
Cookies with ASP
http://www.w3schools.com/asp/asp_cookies.asp
http://riki-lb1.vet.ohio-state.edu/mqlin/computec/tutorials/aspcookie.htm
Thursday, August 14, 2008
Download File Script for ASP
<%
Response.Buffer = True
Dim strAbsFile
Dim strFileExtension
Dim objFSO
Dim objFile
Dim objStream
'Set this to the variable in your GET
Set filename = request.QueryString("wp")
'-- set absolute file location
strAbsFile = Server.MapPath(filename)
'-- create FSO object to check if file exists and get properties
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'-- check to see if the file exists
If objFSO.FileExists(strAbsFile) Then
Set objFile = objFSO.GetFile(strAbsFile)
'-- first clear the response, and then set the appropriate headers
Response.Clear
'-- the filename you give it will be the one that is shown
' to the users by default when they save
Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
Response.AddHeader "Content-Length", objFile.Size
Response.ContentType = "application/octet-stream"
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
'-- set as binary
objStream.Type = 1
Response.CharSet = "UTF-8"
'-- load into the stream the file
objStream.LoadFromFile(strAbsFile)
'-- send the stream in the response
Response.BinaryWrite(objStream.Read)
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
Else 'objFSO.FileExists(strAbsFile)
Response.Clear
Response.Write("Le fichier est inexistant.")
End If
Set objFSO = Nothing
%>
P.S. I hacked this out from some download manager but don't remember it to give proper credit (sorry).
Pause Flash
function paused(sec) {
stop();
var i = sec - 1;
var t = setInterval(function () {
if (i == 0) {
clearInterval(t);
play();
}
i--;
}, 1000);
}
Then in a frame add:
paused (sec); // change sec to the number of seconds for the pause
Wednesday, August 13, 2008
PHP to ASP Quick Reference
Anyway, ASP is much different than PHP, in more ways than one. I won't get into them but if you're struggling to learn it, or if you know ASP but are struggling with PHP this is a very useful reference: http://www.design215.com/toolbox/asp.php
It saved me a lot of time because if you've tried to search for ASP code, like I have, you'll know it is much harder than looking for PHP references.
Quick AJAX Reference
AJAX seems intimidating because it's new and cool but it really isn't. Simply put, it is a combination of JavaScript and a server-side language such as PHP. It's just about sending and receiving data through JavaScript to a server-side encoded page (PHP page) and displaying the output information to a user without refreshing their browser.
I'm finding that each new site that I do, I end up adding a little bit of AJAX flavor, so I'm sure we'll be finding more tips and tricks with it.
Blog Begins
If you find anything useful, link to it and let others know. Thanks!