Showing entries 1 to 10 of 23
10 Older Entries »
Displaying posts with tag: PHP/MySQL/MSSQL (reset)
How To – Configure MySQL to Use UTF-8

Background Knowledge

Using the character set UTF-8 allows for the use of any language, can represent every character in the Unicode character set and is backward compatibility with ASCII. Not to mention is can handle any platform and be sent through many different systems without corruption. With such advantages this is why so many are making the switch.

The following instructions were done on Debian Squeeze v6.04 AMD64 operating system using MySQL v14.14 Distrib 5.1.61.

Solution – Server Configuration

At present MySQL is configured by default to use “latin1″ character set. Here’s how to change MySQL configuration to use UTF-8 character set and collation.

  1. Check MySQL’s current configuration, run the following two SQL statements.

    1
    2
    
    SHOW VARIABLES LIKE '%collation%'; …
[Read more]
How To – Fix MySQL Option Without Preceding Group

Background Knowledge

You try starting, stopping or connecting to MySQL and receive the following error, “Error: Found option without preceding group in config file: /etc/mysql/conf.d/char_collation_set.cnf at line: 1″. The error message my vary but comes to the same issue. MySQL may not start or might experience connectivity issues.

This issue was experienced on Debian Squeeze v6.04 AMD64 system with MySQL v14.14 Distrib 5.1.61.

Solution

This issue is caused by a improperly formatted MySQL configuration file(s) and refers to one missing the group heading (e.g. [mysqld], [mysqld_safe], etc.).

Source: MySQL 5.1 Reference Manual :: 4.2.3.3. Using Option Files
Source: …

[Read more]
How To – Resolve MySQL Error Incorrect Key File for Table

Background Knowledge

I using PHP v5.3.3-7 PDO running a MySQL v14.14 Distrib 5.1.49 on Debian v6.0.4 64-bit and executing a SQL load data infile statement.

I received “PHP Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: 126 Incorrect key file for table ‘/tmp/#sql_66f_0.MYI’; try to repair it”. My database table in this instance is using the storage engine of InnoDB and therefore one can not use the “repair table”.

From my experience I’ve found that this error can mean one of two issues however I have not found information from MySQL confirming this.

Solution – Repair Table

The error message may mean the database table is corrupted and requires a repair.

  1. Run repair table on the …
[Read more]
TaskFreak! v0.6.2 – Customizing Status

Background Knowledge

The progress of a task in TaskFreak! is shown as a percentage value and is not exactly visually appealing to quickly spot the progress. With a few minor alterations we can show the percentage completed bar that fills as the task progresses and a gradient bar indicating the progress along with the percentage value.

This solution was posted by Searcher at Re: Taskfreak Customizing Status.

Solution

  1. Edit at line #268 as shown below.
    Cod Before

    268
    
              <th width="<?php echo FRK_STATUS_LEVELS * 2; ?>%" onclick="freak_sort('statusKey')" colspan="< ?php echo FRK_STATUS_LEVELS ?>" class="sortable">< ?php echo (FRK_STATUS_LEVELS == …
[Read more]
How To – Convert MSSQL Timestamp/Datetime to Unix Timestamp

Background Knowledge

I will explain how to convert a DATETIME (data type) value in Microsoft SQL Server to Unix timestamp and how to convert Unix timestamp to DATETIME. A Unix timestamp is a integer value of seconds since January 1, 1970 at midnight. For further explanation of Unix timestamps refer to Wikiepedia, UnixTimestamp.com or http://unixtimesta.mp/.

Note: This solution only work on dates prior to 2038-01-19 at 3:14:08 AM, where the delta in seconds exceeds the limit of the INT data type (integer is used as the result of DATEDIFF). See source for further details as I have not verified a solution to this problem.

Solutions

Convert Datetime Value to Unix Timestamp (today)

[Read more]
Example of a Basic ODBC (MSSQL Server) Query using PHP

An example of a basic ODBC (MSSQL Server/DSN-Less) query using PHP.

Example of Result Set Returning One Row

1
2
3
4
5
6
7
8
9
      $szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere";
$szDBPswd="PasswordHere";
$szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers WHERE FooID=777";
$rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd);  
$rDBRes = odbc_exec($rDBConnect, $szDBQuery);
$szLastCheck = odbc_result($rDBRes, "LastCheck");
odbc_free_result($rDBRes);
odbc_close($rDBConnect);

Example of Result Set Returning Multiple Rows in an Object

1
2
3
4
5
6
7
8
9
10
11
12
13
14
      $szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere";
$szDBUsername="UsernameHere"; …
[Read more]
TaskFreak! v0.6.2 – Add Unique Ticket/Task Number

Background Knowledge

TaskFreak! does not show within the interface a unique ticket/task number. Depending on the use of TaskFreak! having such a value can have it’s benefits. Since this unique value does already exist in the back end, it will be fairly trivial to render this value within the task list and task details panel. I will show you how this is done using Searcher’s solution posted in the TaskFreak! Forum. There has been some modifications but not much.

Solution

  1. Edit index.php in the root of TaskFreak!. Add the table header column just below line # 248 as follows.

    2
    
              <th width="3%" onclick="freak_sort('itemId')" class="sortable" >< …
[Read more]
PHP – mssql_query() Error

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()

Example of a Basic MSSQL Query using PHP

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 …
[Read more]
PHP – Upgrading v5.2.5 to v5.2.8

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 …
[Read more]
Showing entries 1 to 10 of 23
10 Older Entries »