<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MacLochlainns Weblog &#187; Zend</title>
	<atom:link href="http://blog.mclaughlinsoftware.com/category/zend/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mclaughlinsoftware.com</link>
	<description>Michael McLaughlin's Technical Blog</description>
	<lastBuildDate>Wed, 28 Jul 2010 00:02:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The ereg() function is gone</title>
		<link>http://blog.mclaughlinsoftware.com/2009/12/29/the-ereg-function-is-gone/</link>
		<comments>http://blog.mclaughlinsoftware.com/2009/12/29/the-ereg-function-is-gone/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 08:03:30 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MAMP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://blog.mclaughlinsoftware.com/?p=3381</guid>
		<description><![CDATA[Alas, poor ereg() I abused you well. PHP 5.3 has deprecated ereg() and now we must move forward with preg_match(). Along with that change, somebody asked me to show how to upload images to the file system as opposed to the database. Personally, I think they should be stored in the database. With my bias [...]]]></description>
			<content:encoded><![CDATA[<p>Alas, poor <code>ereg()</code> I abused you well. PHP 5.3 has deprecated <code>ereg()</code> and now we must move forward with <code>preg_match()</code>. Along with that change, somebody asked me to show how to upload images to the file system as opposed to the database. Personally, I think they should be stored in the database.</p>
<p>With my bias toward databases, I threw in a virtual directory mapping in a MySQL database because it doesn&#8217;t natively support an Oracle equivalent <code>BFILE</code> data type. You can see <a href="http://blog.mclaughlinsoftware.com/plsql-programming/how-to-return-a-fully-qualified-bfile-file-name-from-a-function/">this older post</a> how to use the <code>DBA_DIRECTORIES</code> view in Oracle to mimic this behavior.</p>
<p>Naturally, MySQL is the preferred database of the person asking the question. You could also implement this exactly the same in Oracle but you really don&#8217;t want to do so. Using Oracle&#8217;s <em>virtual directories</em> has it&#8217;s own pre-built set of security features. They provide a more robust solution.  </p>
<p>The code is presented as follows (<a href="http://blog.mclaughlinsoftware.com/2009/05/24/mysql-installation-and-more/">setup for MySQL instructions</a>):</p>
<ol start="1">
<li>Create and seed the <code>DIRECTORY</code> table in MySQL:</li>
</ol>
<div style="margin-left:30px">

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- Create a directory table.</span>
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> directory
<span style="color: #66cc66;">&#40;</span> directory_id   int <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>
<span style="color: #66cc66;">,</span> virtual_name   varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">,</span> directory_name varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">-- Seed the table with a virtual directory mapping.</span>
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> directory <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'CMS_IMAGES'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'C:<span style="color: #000099; font-weight: bold;">\\</span>Data'</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

</div>
<ol start="2">
<li>Create a <code>MySQLCredentials.inc</code> <em>credentails</em> file for inclusion in the PHP program:</li>
</ol>
<div style="margin-left:30px">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #666666; font-style: italic;">// Connection variables.</span>
  <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HOSTNAME'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'USERNAME'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;student&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PASSWORD'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;student&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DATABASE'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;sampledb&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</div>
<ol start="3">
<li>Create the PHP uploading program, named <code>MySQLFileUpload.php</code>:</li>
</ol>
<div style="margin-left:30px">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #666666; font-style: italic;">// Set database credentials.</span>
  <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MySQLCredentials.inc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Declare input variables.</span>
  <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">1021</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Upload a file to server in a mapped physical drive location.</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>process_uploaded_file<span style="color: #009900;">&#40;</span>map_virtual_directory<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Successfully Uploaded the file.&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Map a virtual directory to a physical directory.</span>
  <span style="color: #000000; font-weight: bold;">function</span> map_virtual_directory<span style="color: #009900;">&#40;</span><span style="color: #000088;">$virtual</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Return successful attempt to connect to the database.</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysqli_connect</span><span style="color: #009900;">&#40;</span>HOSTNAME<span style="color: #339933;">,</span>USERNAME<span style="color: #339933;">,</span>PASSWORD<span style="color: #339933;">,</span>DATABASE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Print user message.</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Sorry! The connection to the database failed. Please try again later.&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Return error message.</span>
      <span style="color: #b1b100;">print</span> <span style="color: #990000;">mysqli_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Kill the resource.</span>
      <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Initialize a statement in the scope of the connection.</span>
      <span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysqli_stmt_init</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Declare a case insensitive dynamic SQL statement.</span>
      <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT directory_name FROM directory WHERE virtual_name = UCASE(?)&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Prepare the statement.</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_stmt_prepare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #339933;">,</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Bind the input parameter to the prepared statement.</span>
        <span style="color: #990000;">mysqli_stmt_bind_param</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'s'</span><span style="color: #339933;">,</span><span style="color: #000088;">$virtual</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Execute the prepared statement.</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_stmt_execute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          <span style="color: #666666; font-style: italic;">// Bind the result to a local variable.</span>
          <span style="color: #990000;">mysqli_stmt_bind_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #339933;">,</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #666666; font-style: italic;">// FetchPrepare statement and link it to a connection.</span>
          <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_stmt_fetch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$directory</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
          <span style="color: #666666; font-style: italic;">// Return error message.</span>
          <span style="color: #b1b100;">print</span> <span style="color: #990000;">mysqli_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">else</span>
        <span style="color: #666666; font-style: italic;">// Return error message.</span>
        <span style="color: #b1b100;">print</span> <span style="color: #990000;">mysqli_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #666666; font-style: italic;">// Disconnect from database.</span>
      <span style="color: #990000;">mysqli_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Manage file upload.</span>
  <span style="color: #000000; font-weight: bold;">function</span> process_uploaded_file<span style="color: #009900;">&#40;</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/* Assume the application may allow a virtual directory with a trailing backslash or forward
       slash to be stored in the database, and manage both scenarios across Windows and Linux. */</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.Win32.&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;SERVER_SOFTWARE&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\b<span style="color: #000099; font-weight: bold;">\\</span>\/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\b\//&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$directory</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$directory</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$directory</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$directory</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">else</span> <span style="color: #000088;">$directory</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$directory</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\b\//&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #000088;">$directory</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$directory</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">else</span>
        <span style="color: #000088;">$directory</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$directory</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">;</span>  
&nbsp;
    <span style="color: #666666; font-style: italic;">// Check for, move uploaded file, and confirm processing.</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Move temporary cache into a file directory with the uploaded file name.</span>
      <span style="color: #990000;">move_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$directory</span><span style="color: #339933;">.</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Remove this from real code, it's here for example only. ;-)</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Uploaded [&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;] to&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$directory</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Return true to encapsulate the functional logic on success.</span>
	    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span>
      <span style="color: #666666; font-style: italic;">// Return false to encapsulate the functional logic on failure.</span>
	    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</div>
<ol start="4">
<li>Create a web page to test it:</li>
</ol>
<div style="margin-left:30px">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;
  UploadFileFormMySQL.htm
&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id=&quot;uploadForm&quot;
      action=&quot;MySQLFileUpload.php&quot;
      enctype=&quot;multipart/form-data&quot;
      method=&quot;post&quot;&gt;
  &lt;table border=0 cellpadding=0 cellspacing=0&gt;
    &lt;tr&gt;
      &lt;td width=125&gt;Item Number&lt;/td&gt;
      &lt;td&gt;
        &lt;input id=&quot;id&quot; name=&quot;id&quot; type=&quot;text&quot;&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=125&gt;Select File&lt;/td&gt;
      &lt;td&gt;
        &lt;input id=&quot;uploadfilename&quot; name=&quot;userfile&quot; type=&quot;file&quot;&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=125&gt;Click Button to&lt;/td&gt;
      &lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;Upload File&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

</div>
<p>Hope this helps a few folks. I imagine that the prepared statement with bound variables may help a few folks because it&#8217;s not found (at writing) on the <code>php.net</code> web site.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2009/12/29/the-ereg-function-is-gone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows 7 and Zend CE</title>
		<link>http://blog.mclaughlinsoftware.com/2009/11/28/windows-7-and-zend-ce/</link>
		<comments>http://blog.mclaughlinsoftware.com/2009/11/28/windows-7-and-zend-ce/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 04:56:46 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[Microsoft Windows 7]]></category>
		<category><![CDATA[OPAL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://blog.mclaughlinsoftware.com/?p=3183</guid>
		<description><![CDATA[Installed Zend Community Edition on Windows 7 64-bit. It worked easily. You just need to remember to install the JSDK 32-bit version for the Java Bridge. Clear notation about phpMyAdmin and MySQL being separate downloads has been added to the new Zend Community Edition Server (4.0.6), and it clearly does support Windows 7. If you [...]]]></description>
			<content:encoded><![CDATA[<p>Installed Zend Community Edition on Windows 7 64-bit. It worked easily. You just need to remember to install the <a href="http://blog.mclaughlinsoftware.com/2009/07/07/zend-java-bridge-32-bit/">JSDK 32-bit version for the Java Bridge</a>. Clear notation about <a href="http://www.phpmyadmin.net/home_page/index.php">phpMyAdmin</a> and MySQL being separate downloads has been added to the new Zend Community Edition Server (4.0.6), and it clearly does support Windows 7.</p>
<p>If you plan on installing MySQL and Oracle, I would recommend you install MySQL after you install Oracle and the Zend Community Server. However, it doesn&#8217;t matter because both ways work. </p>
<p>That completes my WAMP (Windows, Apache, MySQL, Perl, PHP, or Python) and OPAW (Oracle, Perl, PHP, or Python, Apache, Windows) installations. Actually, I&#8217;m not sure there is an <em>OPAW</em> acronym for a <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29">LAMP</a> stack running Oracle on a Windows platform. OPAL is the acronym for a LAMP stack running an Oracle database, but I&#8217;ve never seen one before for Windows. Therefore, I created one.</p>
<p><span style="font-size:125%;color:blue"><em>My two cents worth &#8230;</em></span> </p>
<p>I&#8217;d vote for clearer guidance on these acronyms. After all, they&#8217;re only purpose appears to be how to market variants of LAMP. The variants that I&#8217;ve seen for LAMP (Linux) are: MAMP (Mac OS X), SCAMP (Santa Cruz Operation), SAMP (Solaris), OAMP (OpenBSD, and WAMP (Windows) for MySQL database versions. The key seems to be swapping the first letter. I&#8217;ve only seen OPAL (Linux) officially for a LAMP stack that uses an Oracle database on a Linux platform. While my OPAW leverages what I perceive as a possible pattern, it may be wrong. Does anybody know what the right way to label these is?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2009/11/28/windows-7-and-zend-ce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Java Bridge 32-bit</title>
		<link>http://blog.mclaughlinsoftware.com/2009/07/07/zend-java-bridge-32-bit/</link>
		<comments>http://blog.mclaughlinsoftware.com/2009/07/07/zend-java-bridge-32-bit/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 03:39:14 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[MAMP]]></category>
		<category><![CDATA[Microsoft XP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OPAL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://blog.mclaughlinsoftware.com/?p=2808</guid>
		<description><![CDATA[I just wanted to see how Zend Server Community Edition might be broken. Performing a full feature install on Windows x64, I confirmed that Zend Server&#8217;s Java Bridge depends on the 32-bit JRE (common sense prevails). Installing it against the JRE 64-bit jvm.dll did raised an exception but none of the instructions address the problem. [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to see how Zend Server Community Edition might be broken. Performing a full feature install on Windows x64, I confirmed that Zend Server&#8217;s Java Bridge depends on the 32-bit JRE (common sense prevails). Installing it against the JRE 64-bit jvm.dll did raised an exception but none of the instructions address the problem.</p>
<p>It&#8217;s one of those simplifying assumptions &#8211; everybody knows 32-bit software works with 32-bit software. Anybody running on Windows XP x64 should know that they may need a JDK 64-bit and both a JRE 64-bit and JRE 32-bit for some applications. For those who don&#8217;t know this, like my students and other newbies, when you run Windows XP the 64-bit stuff goes in the <code>C:\Program Files</code> directory and the 32-bit stuff goes in the <code>C:\Program Files (x86)</code> directory. This lets you develop 32-bit or 64-bit Java applications on the same 64-bit machine.</p>
<p><a href="http://blog.mclaughlinsoftware.com/wp-content/uploads/2009/07/zendbroken.png"><img src="http://blog.mclaughlinsoftware.com/wp-content/uploads/2009/07/zendbroken.png" alt="zendbroken" title="zendbroken" style="border:none" width="268" height="186" class="aligncenter size-full wp-image-2809" /></a></p>
<p>Another tidbit of interest, don&#8217;t choose a full install if you&#8217;ve already installed MySQL. The Zend Community Server isn&#8217;t smart enough to alter the configuration to another port, and their <code>my.ini</code> points to a <code>3306</code> listener port. This causes the MySQL_ZendServer51 service to fail. It also doesn&#8217;t uninstall well. If you don&#8217;t want to clean the Windows Registry, don&#8217;t choose to install a second MySQL.</p>
<p>As an FYI, the Zend installation of MySQL doesn&#8217;t put a password on the root account. Don&#8217;t forget to add one after the install if you go down the full product road. This has the <a href="http://blog.mclaughlinsoftware.com/php-programming/zend-server-installation/">Zend Server Community Edition installation instructions</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2009/07/07/zend-java-bridge-32-bit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
