NAS at Home

July 10, 2010

I have tossed around the idea of purchasing the DLINK DSA-323 for some time but have settled on powering up my old P4 3.0 Ghz and dropped in a couple of hard drives and installed FreeNAS…Life is good.

FreeNAS is built on FreeBSD (Unix). The user interface is very simple to use, and there are number of good how to’s across the web (just give a search of You Tube or Google).

Despite what this particular blog (Bunker Hollow) states, FreeNAS is not a waste of time.

I followed this site (for the most part) to do the setup: Network-Attached Storage With FreeNAS

My System:
P4 3.0Ghz@3.2Ghz
Asus P4C800E Deluxe Motherboard
ATI Radeon 7200 AGP Video Card
2 GB DDR OCZ Platinum RAM
1 X 80 GB WD SATA 7200RPM Hard Drive (OS & Storage)
2 X 1 TB Seagate Barracuda SATA Drives in Software RAID 1 (mirroring)

Infact the FreeNAS installation is so small you could run the system off a flash drive (embedded install), but I don’t recommend this route because the embedded install prevents you from “writing” to the operating system file structure outside of FreeNAS. Making it rather challenging to install additional packages (not required).

Highly recommend this NAS solution if you have an old PC just sitting around doing nothing. I am use mine to serve out files, music, videos, and pictures to my iMAC, PC, Laptop, and Playstation 3.

Highly recommend it.


Simple PHP to MySQL Connection Page

April 10, 2009

Here is an example of a simple PHP page I include with every PHP page I create in a PHP Project. Example:

<?php
//Connection Info for MySQL
$username='root';
$password='thepassword';
$database='northwind';
//Connect to the Database in MySQL Server
$dbconx = mysqli_connect('localhost', $username, $password);

//mysql_connect("localhost",$username,$password);
//@mysql_select_db($database) or die( "Unable to select database");
// mysql_select_db($database, $dbconx);
// Select the database
$db_select=mysqli_select_db($database, $dbconx);
if (!$db_select)
{
die ("Could not select the database:
". mysql_error( ));
}
?>

I save the above script as Connection.php and I include this with a PHP include statement.
include ‘Connection.php’;


Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

March 9, 2009

I have been experiencing this error with PHP files I create on my windows machines but try to run on the Mac machine. 

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required ‘/Users/<user>/Sites/phpApp1/ConnectTest2.php’ (include_path=’.:’) in Unknown on line 0

 

The cause is the permissions for the file and “No Access” for everyone.   So when I modified the permissions (Mac OSX: cmd + i with the file selected) to read & write for everyone all was good.


Installing MySQL on the MAC OSX Leopard

February 16, 2009

Okay, this was more difficult than it needed to be.   Here are my basic steps

1. Download Package (as DMG)
2. Double click package to install.  Install Startup Item and SystemPref
3. Open Terminal
4. cd /usr/local/mysql
5. sudo ./scripts/mysql_install_db
6. sudo chown -R mysql:mysql data
7. /usr/local/mysql/bin/mysqladmin -u root password ‘ <enter password>’
8. Test account login /usr/local/mysql/bin/mysql -u root – p mysql
9. Enter your password when prompted.
Some Useful Websites:

http://www.adobe.com/devnet/dreamweaver/articles/php_macintosh.html

http://foundationphp.com/tutorials/php_leopard.php


To Create the Northwind Database from the SQL text file

1. Open Terminal
2. Login to MySql   /usr/local/mysql.bin/mysql -u root -p
3. Enter your password when prompted
4. type source and then drag the file to the bash terminal window and hit enter.

I will post a more indepth how to as I review my notes and my trial and errors.


PHP & MySQL Functions

November 25, 2008

http://www.w3schools.com/PHP/php_ref_mysql.asp


Normalization Cheat Sheet

November 23, 2008

Using the Bottom up approach

For each view:

1. Create the initial table 0NF

  • List all attributes in the view
  • designate the primary key (PK)
  • show any repearing groups in parenthesis

2. List the violations to 1NF (if any)

Composite attribute handle by:

replacing with atomic attributes

repeating groups handle by:

remove repeating group attributes and place in new table

duplicate the primary key (PK) from the original table to act as a foreign key (FK) in the new table (mark cardinality)

designate a primary key for the new table
3. List the violations to 2NF (if any)

Remove partial depenedencies

  • a non-key attribute that is fully dependent on the part but not all of the primary key in its table
  • table MUST have a composite key in order for a violation to 2NF to occur
  • field A is fully dependent on field B if knowing the value of field B means you know the value of field A

Handle by:

  • move partially dependent attribute(s) to a new table duplicate the part of the primary key that the partially dependent attribute is fully dependent on the place in the new table.
  • the part of the primary key that the partially dependent attribute is fully dependent on acts as a foreign key in the ORIGINAL table designate a primary key for the new table.

4. List the violations to 3NF (if any)

remove transitive dependencies

  • a non-key attribute that is fully dependent on another non-key field
  • a table MUST have 2 or more non-key attributes for a violation to 3NF to occur field A is fully dependent on field B if knowing the value of field B means you know the value of field A

Handle by:

  • move transitively dependent attribute(s) to a new table
  • duplicate the non-key field(s) that the transitively dependent field is dependent on the place in the new table
  • The non-key field(s) that the transitively dependent field is dependent on acts a foreign key in the ORIGINAL table.
  • designate a primary key (PK) for the new table

Merge the view schemas to procude a single conceptual level schema for the database.

Identify duplicate tables (tables that occur in many different views and have the same primary key)

A single coply of the table is placed in the conceptual schema ensure all non-key attributes from the various views are included ensure all relationships to other tables, from the various views, are included

copy tables that exist in a single view into the conceptual schema ensure all relationships to other tables in the view are included.


Fatal error: Call to undefined function mysql_connect()..(Part 2)

November 17, 2008

Now lets get MySQL up and running.

1. Install MySQL Community Server found here

MySQL
MySQL

2. Install MySQL GUI Tools (Recommended)
mysqltools1
3. Copy libmysql.dll from c:\PHP to C:\Windows\systems32
4. Download php_mysqli.dll here and extract the contents to c:\windows\system32
mysqlind1
mysqlind2
5. copy php_mysql.dll from C:\PHP to c:\windows\system32
6. Reboot your PC
7. open http://localhost/MyPHPInfo.php (my sample file if you don’t have one, save with extension .php in your c:\inetpub\wwwroot directory) again and you should see an entry for mysql

**Also note that you should see extension_dir=”c:\PHP\ext” ** Confirm


Fatal error: Call to undefined function mysql_connect()..(Part 1)

November 15, 2008

This error is due to mysql dlls not being in the right place and the php parser not knowing where to look for the extension dlls….below is my working solution on Vista SP1 and XP SP3.

I have had a hard time getting PHP and MySQL on Windows XP and Vista to actually talk to one another.   I have search the web under this post title and found many suggestions, recommendations, and options to try with no success.   I finally solved this issue myself, so I thought it best to post it for others to learn from what I did.

The biggest issue with any solution sources out there is lack of screen shots or lack of descriptions of what their actual setup is and not just what they did to solve it.  A minor criticism I know.. it is my hope that this post will improve on those very things other posts/web pages missed.

I will provide a bit more detail than just the solution to this error message (which I will denote).

System:

  • Windows XP Professional Service Pack 3 installed
  • or Windows Vista Home Premium w/ Service Pack 1
  • IIS (Internet Information Server) installed and running
  • Downloaded the php-5.2.6-Win32.zip file from php.net and unzip this to c:\PHP
  • Installed MySQL Community Server (see below) from MySQL.com
  • I also installed (and recommend) MySQL GUI Tools found on this page

Once you have unzipped the zip file for PHP into c:\PHP directory you are ready to setup PHP on IIS and then created the conduit for PHP and MySQL to talk to each other.

PHP on IIS setup (**note there is a Windows XP setup and a Vista setup**)

Windows XP Setup (assumes IIS is installed)

PHP Setup Part 1

  1. Download the php-5.2.6-Win32.zip file and unzip it to c:\PHP folder
  2. Open php.ini-recommended file in Notepad (or any other text editor)
  3. Save this file as php.ini in your C:\PHP folder (**NOT in c:\windows as with Apache)
  4. Search the php.ini file for the line  extension_dir = “./”
  5. Change this to read  extension_dir = “c:\PHP\ext”
  6. Now search for the line in the php.ini file ;extension=php_mysql.dll
  7. Right below this line there should be the line ;extension=php_mysqli.dll
  8. Remove the semi-colon from each of those lines

Result:

...

; Directory in which the loadable extensions (modules) reside.
;extension_dir = "./"

extension_dir = "c:\PHP\ext"
...
;extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=libmysql.dll
...

PHP Setup Part 2

1. Start Menu –> Run –> inetmgr.exe

inetmgr

2. Expand the tree on the left to show the Website folder in IIS (for PHP5 on Apache Install)

inetmgr1

3. Right click on the Website folder and choice properties

intemgr2

4. Click on Home Directory Tab and then click Configuration

inetmgrprops2

5. In the Mappings tab (sorted alphabetically) search for a PHP entry, most likely there is none, so add it
6. Then set the Executable to c:\php\php-cgi.exe and the extension to be php

inetmgr47. Click Okay

8. Stop and restart IIS
9 . Create a simple phpinfo file in notepad to test your setup.
10. Save this a MyPHPInfo.php in your c:\inetpub\wwwroot\ folder (default setup of IIS)
11. Start Menu –> Run –> http://localhost/MyPHPInfo.php

A page like this should appear:

phpinfo1If not, you may need to restart your machine and try again.


CCL Query to Lookup Rx_Verify_Flag

November 14, 2008

The code to lookup the Order Review tab information in DCP Tools–> Order Catalog

SELECT
O_ACTION_TYPE_DISP = UAR_GET_CODE_DISPLAY(O.ACTION_TYPE_CD)
, O.ACTION_TYPE_CD
, O_CATALOG_DISP = UAR_GET_CODE_DISPLAY(O.CATALOG_CD)
, O.CATALOG_CD
,O.RX_VERIFY_FLAG
, OC.CKI
, OC.PRIMARY_MNEMONIC
FROM
ORDER_CATALOG_REVIEW O
, ORDER_CATALOG OC
PLAN O
WHERE O.action_type_cd = 2530.00 ; DELETED or VOID
JOIN OC
WHERE O.catalog_cd = OC.catalog_cd
AND OC.activity_type_cd = 705.00 ; Pharmacy
WITH NOCOUNTER, SEPARATOR=" ", FORMAT

Note FLAG = 2 (Required)  = 1 (Not Required)


Northwind SQL Script for MySQL

November 14, 2008

Here is the script for a Northwind Database in mySQL.


Follow

Get every new post delivered to your Inbox.