MySQL File Access, Access Denied
December 31st, 2008
If you need to access files for importing directly from MySQL you may have encountered an error stating the following.
Access denied for user: 'user@localhost' (Using password: YES)
The user used to execute the import needs the FILE privilege in order to complete a command similar the one below.
LOAD DATA INFILE filename
INTO TABLE products
FIELDS TERMINATED BY '|'
LINES [...]
Set PHP Include Path in htaccess
December 26th, 2008
If you do not want to change the include_path directories (or you don’t have access to php.ini) you can still set the include_path value within your root .htaccess file.
Update/Create /doc_root/.htaccess
Unix/Linux Servers
php_value include_path "/path/to/include"
Windows Servers
php_value include_path "C:/path/to/include"
PHP
To call the include within PHP do the following:
require_once('file.php');
The file above is in /doc_root/include/file.php
Options
Multiple include directories
If you have multiple include [...]
GoDaddy Now Allows Direct Access to MySQL on Shared Hosting Plans
December 25th, 2008
GoDaddy.com has recently added the ability for shared hosting plans owners to access their MySQL databases directly.
Once you start the MySQL creation process you will have the option to Allow/Disallow direct access.
This is very useful if you do not want to use phpMyAdmin to administer your MySQL database such as an initial import that exceeds [...]
MySQL Match Dates with a UNIXTIME Field
December 19th, 2008
Here is how to grab and compare a date directly from a MySQL query if you are storing your dates as UNIXTIME.
SELECT
*
FROM
table
WHERE
MONTH(FROM_UNIXTIME(unixtime_fieldname)) = MONTH(CURDATE())
AND DAY(FROM_UNIXTIME(unixtime_fieldname)) = DAY(CURDATE())
AND YEAR(FROM_UNIXTIME(unixtime_fieldname)) = YEAR(CURDATE())
This particular query is looking for any records that have the same month, day and year as today.
[...]
Remove/Force www on Your Domain and 301 Redirect
December 18th, 2008
You want to ensure that Google and other SEs only see one domain so you don’t penalized for duplicate content (www and non-www indexed pages are not the same and counted as duplicates).
.htaccess
To redirect to domain.com and 301 existing pages:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
To redirect to www.domain.com and 301 existing pages:
RewriteEngine [...]
MySQL Replace String, Similar to PHP str_replace()
December 17th, 2008
Very handy function if you need to replace a string in your MySQL database tables.
UPDATE table
SET field = REPLACE(field, 'Old Value', 'New Value')
Reference
MySQL String Functions
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html
Move Your Wordpress Blog from Development/Staging to Production
December 8th, 2008
When you are finished with development and staging reviews there are some database changes that need to be made in order for your Wordpress blog to work properly.
You can use any MySQL tool you have available, my favorite is Navicat.
Options Table
The options table stores all of the main settings for your blog. You will need [...]
Return Single Value with ExecuteScalar, Stored Procedures and C#
December 3rd, 2008
A common query is to return a single value from a SQL query such as an aggregate to get the total number of rows in a table. I will show you how to do just that with SQL Server Stored Procedures and C#.
Preparation
You will need some table data to query against. I am using the [...]
Sample Databases for SQL Server
December 2nd, 2008
Microsoft provides some sample databases to use to experiment with your code; because you wouldn’t dare query against your live customer data with untested code right?
Samples
http://www.codeplex.com/SqlServerSamples
SQL Server Database Examples
http://www.codeplex.com/SqlServerSamples#databases
I use the Northwind tables from the SQL Server 2000 Sample DBs.
How to Install the Northwind Sample Database
Unzip the sample database files you just downloaded
Open SQL Server Management [...]
Apache WAMP vhost with SSL Configuration
November 28th, 2008
If you are developing in a Windows environment and need to host multiple sites on your Apache development workstation or server here are some tips for setting up your Apache configuration.
Download and install XAMPP
http://www.apachefriends.org/en/xampp-windows.html
Verify apache is running after installation
<a href="http://localhost" target="_blank">http://localhost</a>
NOTE: If you are also running IIS you will need to disable socket pooling that [...]









