Binary Expressions

Next Page »

2009-5-5

Client-side Image Maps with XHTML 1.1 Strict

Filed under: — Adam @ 8:16 am

I oddly just realized now that Mozilla Firefox is not handling client-side image maps correctly as it should with a DTD of XHTML 1.1 Strict in text/html. I will not go into test cases unless one finds it necessary as everything has been laid out in the two links below. However, why has this not been resolved or is there a proper solution to this matter? I have not been able to find a answers and oddly this issue has been brought up back in 2001. One would think enough time has past.

Any explanation, comments, or help would be greatly appreciated.

Source: Image map handling
Source: Bug 109445 – Referencing a client-side image map declared with id attribute doesn’t work in text/html (usemap)

2009-4-28

PHP – mssql_query() Error

Filed under: — Adam @ 7:16 am

Background Knowledge


I’m running PHP v5.2.9-2 with SQL Server 2005 Express on Windows Server 2003 R2 SP2.

Error Message


Warning: mssql_query() [function.mssql-query]: message: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (severity 16)

Solution


Specify the database columns within your database query (select filed1, field2 from foo). Avoid doing queries with the wildcard (*), select * from foo.

Source: PHP Manual on MSSQL_Query()

2009-4-23

Example of a Basic MSSQL Query using PHP

Filed under: — Adam @ 5:22 pm

An example of a basic MSSQL (Microsoft SQL Server/SQL Server Express) query using PHP.

1
2
3
4
5
6
7
8
9
$szQry = "SELECT column1, column2 FROM foo";
$szDBConn = mssql_connect("host","username","password");
mssql_select_db("database_name", $szDBConn);
$saResults = mssql_query($szQry, $szDBConn);
while($obResults = mssql_fetch_row($saResults))
{
   echo $obResults[0]." ".$obResults[1];
}
mssql_close($szDBConn);

Comments/description of Example

Line #1
SQL statement that will be sent to the MySQL database server.
Line #2
MSSQL database login credentilas; host (127.0.0.1), username and password.
The “host” is the server name or IP address of your database server. If your host has multiple instances the “host” value would be formatted like so “foo\bar”. If your using SQL Server Express the “host” name locally would be “.\SQLEXPRESS”.
Line #3
Select database using the login credentials provided above.
Line #4
Send SQL statement to database.
Line #5-8
Fetch results returned back from the SQL statement. I use a while loop to enumerate through each row of results returned. If you know only one row is going to be retunred the while loop is not necessary.
Line #9
Close database connection.

2009-2-12

PHP – Upgrading v5.2.5 to v5.2.8

Filed under: — Adam @ 1:05 pm

Background Knowledge


The following is the process I took to upgrade a web server with PHP v5.2.5 to PHP v5.2.8 running on OpenBSD. PEAR is already installed on this system and up to date. I wasn’t sure if I should exclude PEAR at install or not so therefore did not tell the configurator to exclude PEAR at install.

Installation Process


  1. Download the latest stable PHP release from command prompt # wget http://ca.php.net/get/php-5.2.8.tar.gz/from/a/mirror
  2. # tar -zxvf php-5.2.8.tar.gz
  3. ./configure –with-mysql=/usr/local –with-mssql=/usr/local –with-apxs –with-zlib-dir=/usr/lib –with-config-file-path=/var/www/conf –with-iconv=/usr/local/bin/iconv –enable-exif –enable-mbstring –enable-calendar
  4. # make
  5. # make test
  6. # make install
  7. # make clean

As far as I could tell in the PHP 5 ChangeLog since at least PHP v5.2.5 there has not be any changes made to the php.ini configuration file. Therefore I chose to leave the PHP configuration file (php.ini) that was being used with PHP v5.2.5 for PHP v5.2.8.

Issues


  1. At configure I received the following message “checking for a sed that does not truncate output… (cached) /usr/bin/sed
    expr: syntax error ./configure[2322]: test: 0: unexpected operator/operand expr: syntax error ./configure[2337]: test: 0: unexpected operator/operand”

I’m not sure what to make of this error message. I tried to search on Google but was not successful finding any answers. I tested my PHP installation and all appears to be okay. If anyone knows what exactly this error means and how to resolve it please let me know.

2008-12-5

MySQL – Can You Concatenate Strings From a Column Into a Single Row?

Filed under: — Adam @ 1:56 pm

How would one concatenate strings from a column (multiple rows) into a single row using MySQL? I see its possible with MS SQL Server 2005 and above. Any incite into how to achieve this in MySQL would be much appreciated.

MS SQL Server 2005 – Example


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SELECT Web_Account_ID,
GroupNameConcat = REPLACE(
	(
	SELECT
		Web_Account_Group_Name_ID AS [DATA()]
	FROM
		tblWebAccountGroup WAG
	WHERE
		WAG.Web_Account_ID = WA.Web_Account_ID
	ORDER BY
		Web_Account_Group_Name_ID
            FOR XML PATH ('')
        ), ' ', ',')
FROM tblWebAccounts WA
ORDER BY Web_Account_ID

Query Results Example


MS SQL Server 2005 query example

Source: aspfaq.com – How do I concatenate strings from a column into a single row?

2008-11-5

C#.Net – Parse Error Could Not Load Type

Filed under: — Adam @ 2:09 pm

Background Knowledge


My web application ran fine locally but then experienced the “Prase Error Could Not Load Type” error message when I copied the files to the web server. In my case I was producing a web application using Visual Studio 2005 and coding in C#.NET.

Example of Error Message


Server Error in ‘/CustomErrorPages’ Application.


Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type ‘CustomErrorPages.WebForm1′.

Source Error:

Line 1: < %@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CustomErrorPages.WebForm1" %>
Line 2:
Line 3: < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Source File: /CustomErrorPages/WebForm1.aspx Line: 1

Solutions


  • Make sure you compiled your project.
  • Make sure your bin folder is in the correct location with the DLL, in this example case “/bin/WebForm1.dll”.
  • Make sure that you created a virtual directory or application root for your project.
  • Make sure you have the correct .NET Framework set in IIS that is required for the application.
  • Make sure you copied all the required application files.

2008-10-23

TaskFreak! v0.6.2 – Tweaking Priority Menu

Filed under: — Adam @ 10:42 am

Background Knowledge


For some reason or another the priority menu in the edit task panel is not wide enough and therefore it cuts off the priority names. This can be easily fixed by modifying some inline CSS. Yes I agree this should be done within the skin’s CSS file, however there is nothing present in the CSS file to alter that I could find.

(more…)

TaskFreak! v0.6.2 – Add My Projects List

Filed under: — Adam @ 10:17 am

Background Knowledge


TaskFreak! presently does not have a means via the web interface to present a complete list of tasks for which the current user is the project leader. I will show you how to add “My Projects” list based on bpiper’s solution with a slight difference. My solution is almost identical to bpiper’s but with a different approach to continue support of the supported interface languages. To do this each supported language file will require to be edited.

Thanks to bpiper for posting your solution.

(more…)

2008-10-14

Pear::Date Returned Timezone is Wrong

Filed under: — Adam @ 1:05 pm

Background Knowledge


I’m trying to determine the difference in minutes between two timestamps. I’m using Pear::Date to do this. The issue comes into play when I noticed that the wrong timezone was being used by Pear::Date, UTC. If I do not use Pear::Date the timezone is set correctly.

I have tried using date_default_timezone_set() and it does set the timezone back, however I feel this shouldn’t be necessary as the default timezone should be used. I have been using date_default_timezone_get() to determine what timezone is being used.

It’s my understanding that Pear::Date uses UTC when it is unable to determine the default timezone. As far as I know I have the default timezone set correctly and with a valid ID (see below). I was able to determine that the timezone changed from my default timezone to UTC after I used Date::setFromDateDiff(). This does not seem right at all.

I have checked the following.

  • Pear v1.7.2 stable
  • Pear::Date v1.4.7 stable
  • php.ini (default timezone) – date.timezone = “Canada/Saskatchewan”
  • phpinfo() – Correct configure file being loaded, /var/www/conf/php.ini.
  • phpinfo() – Under Date, date/time support is enabled.
  • phpinfo() – Default timezone – Canada/Saskatchewan
  • phpinfo() – date.timezone - Canada/Saskatchewan / Canada/Saskatchewan

PHP Code Test Case


1
2
3
4
5
6
7
8
9
require_once("Date.php");
 
$obFirstDate = new Date('20081014155640');
$obSecondDate = new Date(date("YmdHis",time()));
 
$obDateSpan = new Date_Span();
$obDateSpan->setFromDateDiff($obFirstDate, $obSecondDate);
echo (int)$obDateSpan->toMinutes();
echo "<br />".date_default_timezone_get();

Solution – Unknown


Does anyone have any suggestions where to look or what to do to fix this problem?

2008-10-8

Using short if statement in programming

Filed under: — Adam @ 2:50 pm

In many programing languages it is possible to shorten if statements using what’s called the ternary operator. It is sometimes referred as the “one line if statement” or the “short if statement”. This can help at times to produce cleaner code, however use this operator wisely as it is not always best to be used for more complicated statements.

PHP Example of an if statement


1
2
3
4
5
6
7
8
if($nFoo > 0)
{
   echo "I'm at the work.";
}
else
{
   echo "I'm at home.";
}

PHP Example using the ternary operator


1
echo $nFoo > 0 ? "I'm at the work." : "I'm at home.";

The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.

Source: Wikipedia on Ternary Operator
Source: PHP Manual: Comparison Operators

2008-10-7

How To – Pad Zeros (prefix or suffix)

Filed under: — Adam @ 1:00 pm

Background Knowledge


There is certain times when one needs to pad zeros to the beginning (prefix) or ending (suffix) of a integer.

Below is what I came up with for a solution in JavaScript. All one has to do is call the function with the integer value, the length (integer) of the padding and position to place the padding. Use “start” for the prefix or use “end” for the suffix. Please lets see some comments on how to improve this small block of code.

Solution


1
2
3
4
5
6
7
8
9
10
11
function fnPaddingZeros(nInterger,nPaddingLength,szPaddingPos)
{
	//convert integer to string
	nInterger=nInterger.toString();
	while(nInterger.length < nPaddingLength)
	{
		if(szPaddingPos == "start") { nInterger = '0' + nInterger; }
		else if(szPaddingPos == "end") { nInterger = nInterger + '0'; }
	}
	return nInterger;
}

How To – Remove Leading Zeros

Filed under: — Adam @ 11:49 am

Solutions

Using PHP function intval().

Code example: echo intval(“05″);
Returned value: 5

Using PHP function ltrim().

Code example: echo ltrim(“005″,”0″);
Returned value: 5

Next Page »

Take back your mailbox - CAUCE.org

Powered By Wordpress PHP: Hypertext Preprocessor MySQL Powered Download Juice, the cross-platform podcast receiver
Proud To Be Canadian Get Firefox Valid XHTML Valid CSS
<NO>OOXML Logo


21 queries. 1.007 seconds.
Copyright © 2004 - 2005 by Adam Douglas