<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Dynamic Web</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/" />
<modified>2005-03-28T22:15:18Z</modified>
<tagline></tagline>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8</id>
<generator url="http://www.movabletype.org/" version="3.14">Movable Type</generator>
<copyright>Copyright (c) 2005, dimitri</copyright>
<entry>
<title>class 08</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/03/class_08.html" />
<modified>2005-03-28T22:15:18Z</modified>
<issued>2005-03-28T21:23:05Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.224</id>
<created>2005-03-28T21:23:05Z</created>
<summary type="text/plain">javascript code easy to steal. Introduction to JavaScript JavaScript is a simple, interpreted programming language with object-oriented capabilities. Although it has the word &quot;Java&quot; in its name, it is not particularly related to the Java programming language developed by Sun....</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>javascript code easy to steal.</p>

<p>Introduction to JavaScript<br />
JavaScript is a simple, interpreted programming language with object-oriented capabilities. Although it has the word "Java" in its name, it is not particularly related to the Java programming language developed by Sun. It was actually created by Netscape for use on the client-side in their Navigator browser, and on the server-side in their Enterprise server products. Its popularity now resides mostly on the client-side and it offers dynamic website developers the ability to create interactivity without having to request additional pages from the server. In some ways, it can mimic some of Perl's functionality while functioning solely within the browser, and without the aid of a call to the web server. Also, note that like Perl, JavaScript is case-sensitive, so be careful and be consistent in the naming of your variables and functions. It's commonly used for such tasks as:</p>

<p>    * Popup Windows<br />
    * HTML Form Interaction<br />
    * Image Swapping<br />
    * Browser Redirection </p>]]>

</content>
</entry>
<entry>
<title>class 07</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/03/class_07.html" />
<modified>2005-03-11T16:44:14Z</modified>
<issued>2005-03-11T14:33:14Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.199</id>
<created>2005-03-11T14:33:14Z</created>
<summary type="text/plain">database holds the comment lastest comment is an interesting idea relationship of information that builds the community what does the user get and admin get. laundry list: news.yahoo.com email: send message- perl talk to send mail... works only with UNIX...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>database holds the comment</p>

<p>lastest comment is an interesting idea</p>

<p>relationship of information that builds the community<br />
what does the user get and admin get.</p>

<p><br />
laundry list: news.yahoo.com</p>

<p></p>

<p>email:</p>

<p>send message-</p>

<p>perl talk to send mail...  works only with UNIX</p>

<p>perl talk to SMTP -> net::SMTP</p>

<p>sendmail is on the box; SMTP is a trusted machine on the net somewhere.</p>

<p>receiving-</p>

<p>perl talks with pop3 -> net::POP... and many others mail::box....</p>

<p>CPAN is your friend some simple code line for how a module is using.</p>

<p>local folder can be a place for modules</p>

<p>get subject line.... example</p>

<p>token to get text out of the message</p>

<p>using a variable get you around various characters which might effect perls actions.</p>

<p><br />
file</p>

<p>< read a file<br />
>. write<br />
>> append</p>

<p>-s for the size<br />
-e if a file exists</p>

<p>encoding-<br />
type: multipart/mixed</p>

<p><br />
cut and paste can be used from CPAN</p>

<p>friendster model</p>

<p>The Main Concept<br />
Friendster.com is a social networking site developed by Jonathan Abrams with the intention of creating the largest on-line house party - everyone at the party is a "friend of a friend" - which is a common way for people to meet in the real world. Thus, the site is only as interesting as the number of "friends" who agree to sign up. Friendster has already reached that tipping point as over 1.5 million people have signed up just in the past two and a half months. By allowing users to see friends of friends, you can create a somewhat "trusted" social network within which an individual can socialize through messages, photos, match suggestions, introductions, etc. The number of people you have access to is directly proportional to the number of friends you have. From a technical standpoint, some of the main features include:</p>

<p>    * Session Management<br />
Like any site with user accounts, Friendster uses session management to uniquely identify a user. One can only edit their profile, photos, friends, etc if they have successfully logged into the site. Once they are logged in, relevant info such as their user ID is stored in the session. Friendster also allows the "Save My Password Info" feature. In this case, extra information is set in the cookie on the user's computer which allows them to "auto-login".</p>

<p>    * Creating, Updating, and Display of User Profile<br />
#</p>

<p>One of the main things to do on Friendster is to tell other user's about yourself if they happen upon your name. This is done in one's profile. Users fill out an HTML form, and the information is saved in the Friendster database.</p>

<p>In the database, once can imagine that there is a member_profile table where this information is stored, along with a foreign key, "member_id", which matches a particular profile with a particular member. When someone else goes to look at a user's profile, this information is accessed and formatted for easy reading by the interested person. </p>

<p>for the rest below go to class 07 notes:</p>

<p>    * Creating, Deleting, and Display of Friends<br />
    * Creating, Deleting, and Display of Testimonials<br />
    * Creating, Deleting, and Display of Messages<br />
    * Uploading and Deleting of Images<br />
    * Connection Determination<br />
    * Filterable Display of Users in Social Network<br />
    * E-Mail Notification </p>

<p><br />
friends waiting for approval</p>

<p>TABLELAND!!!!! (kekeke)</p>

<p>table linking to direct the infomation in a better way. but in my case there are just a few. Friendster has tooo much stuff going on.</p>

<p>remember the file find widget... looks in to the hard drive to find a file and links in into the code for upload ing and such... (see class05 and 06)</p>

<p><br />
ahhhhhh  friends of friends see the connections.<br />
</p>]]>

</content>
</entry>
<entry>
<title>shawn&apos;s code</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/03/shawns_code.html" />
<modified>2005-03-11T16:22:21Z</modified>
<issued>2005-03-11T06:21:44Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.200</id>
<created>2005-03-11T06:21:44Z</created>
<summary type="text/plain">#!/usr/bin/perl -w #use strict; use MIME::Parser; use MIME::Entity; use MIME::Base64; use Net::POP3; #use Net::POP3_ssl; use XMLRPC::Lite; my $username = &apos;myusername&apos;; ## CHANGE THIS LINE my $password = &apos;mypassword&apos;; ## CHANGE THIS LINE my $pop = Net::POP3-&gt;new(&apos;mymailserver&apos;, Timeout =&gt; 15); ##...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Writen Code</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>#!/usr/bin/perl -w </p>

<p>#use strict; <br />
use MIME::Parser;<br />
use MIME::Entity;<br />
use MIME::Base64;<br />
use Net::POP3;<br />
#use Net::POP3_ssl;<br />
use XMLRPC::Lite;</p>

<p>my $username = 'myusername'; ## CHANGE THIS LINE<br />
my $password = 'mypassword';  ## CHANGE THIS LINE<br />
my $pop = Net::POP3->new('mymailserver', Timeout => 15);  ## CHANGE THIS LINE<br />
my $max_chars = 70;  # Number of chars to allow in a line of text from an incoming message ## CHANGE THIS LINE<br />
my $temp_folder = "/path/to/my/tmp/folder/"; ## CHANGE THIS LINE<br />
my $image_output_folder = "/path/to/where/the/images/or/video/should/be/saved/"; ## CHANGE THIS LINE<br />
my $image_output_folder_relative = "http://servername/relative/path/to/images/or/video/";  ## CHANGE THIS LINE<br />
my $delete_messages = 1;<br />
my $delete_temp_files = 1;<br />
my $print_output = 1;<br />
my $post_to_blog = 1;<br />
my $blog_xmlrpc_url = "http://myserver/path/to/mt/mt-xmlrpc.cgi"; ## CHANGE THIS LINE<br />
my $blog_id = 2; ## CHANGE THIS LINE<br />
my $blog_username = "blogusername"; ## CHANGE THIS LINE<br />
my $blog_password = "blogpassword"; ## CHANGE THIS LINE<br />
my $umask = '0002';  # File creation to 775, 0022 would be 755<br />
$umask = oct($umask) if $umask =~ /^0/;</p>

<p>if ($pop->login($username, $password)) <br />
{<br />
        umask $umask;</p>

<p>        print(localtime() . "\n");<br />
        <br />
        my $parser = MIME::Parser->new;<br />
        $parser->output_dir($temp_folder);<br />
         <br />
        my $msgnums = $pop->list; # hashref of msgnum => size<br />
        my $messagenum = 0;<br />
        foreach my $msgnum (keys %$msgnums) <br />
        {<br />
                my $msg = $pop->get($msgnum); <br />
                <br />
               	###<br />
                # TO GET RAW DATA<br />
                ###<br />
                #foreach my $messageline (@$msg)<br />
                #{<br />
                #       chomp($messageline);<br />
                #       print $messageline;<br />
                #}</p>

<p>                my $entity = $parser->parse_data($msg);<br />
                #my $entity = $parser->parse(\*STDIN); // For testing with message file  -- perl myphoto.pl < message<br />
                <br />
                ###<br />
                # GET MESSAGE HEADER<br />
                ###<br />
                my $msg_head = $entity->head;<br />
                my $subject = "";<br />
                my $to = "";<br />
                my $from = "";<br />
                my $body = "";<br />
                my $attachment = "";<br />
                my $attachment_type = "";<br />
                my $attachment_relative = "";<br />
                <br />
                ##<br />
                # GET MESSAGE SUBJECT<br />
                ##<br />
                if ($msg_head->count('Subject') > 0)<br />
                {<br />
	                $subject = $msg_head->get('Subject');            <br />
                }<br />
                <br />
                ##<br />
                # GET MESSAGE FROM<br />
                ##<br />
                if ($msg_head->count('From') > 0)<br />
                {<br />
	                $from = $msg_head->get('From');<br />
	                if ($from =~ /<(.*)>/)<br />
		            {<br />
		            	$from = $1;<br />
		            }<br />
	            }<br />
	            <br />
                ##<br />
                # GET MESSAGE TO<br />
                ##<br />
	            if ($msg_head->count('To') > 0)<br />
	            {<br />
	                $to = $msg_head->get('To');<br />
	                if ($to =~ /<(.*)>/)<br />
		            {<br />
		            	$to = $1;<br />
		            }	                <br />
	            }<br />
                <br />
                ###<br />
                # GET MESSAGE PARTS (BODY AND ATTACHMENTS)<br />
                ###<br />
                my @parts=$entity->parts;<br />
                my $partnum = 0;</p>

<p>                my $mime_message_body;<br />
				my $is_mime = 0;<br />
                while(my $part = shift(@parts)) <br />
                {       <br />
                		$is_mime = 1;  # Yes we have a mime message<br />
                        my $type=$part->head->mime_type || $part->head->effective_type; <br />
                        if ($type =~ /image\/jpeg/ || $type =~ /image\/jpg/)<br />
                        {               <br />
                                # Give me the entire body as one string (probably bad because these could be BIG images)<br />
                                my $image = $part->bodyhandle->as_string;<br />
                                my $file_name = "picture_" . time() . $partnum . $messagenum . ".jpg"; ## Make names uinque<br />
                                my $image_file = $image_output_folder . $file_name;<br />
                                my $fh = new FileHandle "> $image_file";<br />
                                if (defined $fh) {<br />
                                        print $fh $image;<br />
                                        $fh->close;<br />
                                }<br />
                                $attachment = $file_name;<br />
                                $attachment_type = "jpeg";<br />
                                $attachment_relative = $image_output_folder_relative . $file_name;<br />
                        }                       <br />
                        elsif ($type =~ /text\/plain/i || $type =~ /text\/html/i)<br />
                        {<br />
                                # Plain Text portions or attachments<br />
                                my $message_bodyhandle = $part->bodyhandle;<br />
                                $mime_message_body = $message_bodyhandle->as_string;<br />
								<br />
								@mime_message_array = split('\n',$mime_message_body);<br />
								my $done = 0;<br />
								foreach $message_line (@mime_message_array)<br />
								{<br />
								    $message_line =~ s/<.*>//gi; # Strip out any HTML tags<br />
								    <br />
									if ($message_line =~ /^\n/ ||<br />
											$message_line =~ /^\s*\n/ ||<br />
											$message_line !~ /\w/)<br />
									{<br />
									   # Ignore blank lines<br />
									}<br />
									elsif (length $message_line  > $max_chars)<br />
									{<br />
									   # Ignore lines too long to be text messages<br />
									}<br />
									elsif (!$done)<br />
									{<br />
										$message_body = $message_line; # Only grabbing first line<br />
										$done = 1;<br />
									}                                <br />
                                }<br />
                                $body = $message_body;<br />
                        }<br />
                        elsif ($type =~ /video\/3gpp/i)<br />
                        {<br />
                                # Video Mail<br />
                                # Give me the entire body as one string (probably bad because these could be BIG)<br />
                                my $video = $part->bodyhandle->as_string;<br />
                                my $file_name = "video_" . time() . $partnum . $messagenum . ".3gp"; ## Make names uinque<br />
                                my $video_file = $image_output_folder . $file_name;<br />
                                my $fh = new FileHandle "> $video_file";<br />
                                if (defined $fh) {<br />
                                        print $fh $video;<br />
                                        $fh->close;<br />
                                }<br />
                                $attachment = $file_name;<br />
                                $attachment_type = "3gpp";<br />
                                $attachment_relative = $image_output_folder_relative . $file_name;<br />
                        }<br />
                        else<br />
                        {<br />
                                print "Other Types " . $type . "\n\n"; # OUTPUT<br />
                        }<br />
                        $partnum++;<br />
                }<br />
                <br />
                ##<br />
                # IF IT ISN'T A MIME MESSAGE (NO ATTACHMENTS)<br />
                ##<br />
                if (!$is_mime)<br />
                {<br />
					###<br />
					# GET MESSAGE BODY LINES<br />
					###<br />
					$msg_body = $entity->body;<br />
					my $message_body = "";<br />
					my $done = 0;<br />
					foreach $message_line (@$msg_body)<br />
					{<br />
						if ($message_line =~ /^\n/)<br />
						{<br />
						<br />
						}<br />
						elsif (!$done)<br />
						{<br />
							$message_body = $message_line;<br />
							$done = 1;<br />
						}<br />
                    }<br />
                   	$body = $message_body;<br />
                }<br />
                <br />
                chomp($to);<br />
                chomp($from);<br />
                chomp($subject);<br />
                chomp($body);<br />
                <br />
                if ($post_to_blog)<br />
                {<br />
                    my $attachment_html = "";<br />
                    <br />
                    if ($attachment_type eq "jpeg")<br />
                    {<br />
                        $attachment_html = "<img src=\"$attachment_relative\">";<br />
                    }<br />
                    elsif ($attachment_type eq "3gpp")<br />
                    {<br />
                        $attachment_html = "<br />
                          <OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" WIDTH=\"320\" HEIGHT=\"257\" CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab\"><br />
                              <PARAM name=\"SRC\" VALUE=\"$attachment_relative\"><br />
                              <PARAM name=\"AUTOPLAY\" VALUE=\"false\"><br />
                              <PARAM name=\"CONTROLLER\" VALUE=\"true\"><br />
                            <EMBED SRC=\"$attachment_relative\" WIDTH=\"320\" HEIGHT=\"257\" AUTOPLAY=\"false\" CONTROLLER=\"true\" PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\"></EMBED><br />
                          </OBJECT>             <br />
                        ";<br />
                    }<br />
		<br />
			my $postresult=XMLRPC::Lite<br />
               		->proxy($blog_xmlrpc_url)<br />
               		->call('metaWeblog.newPost',$blog_id,$blog_username,$blog_password,<br />
            			{<br />
            			'title'=>$subject,<br />
            			'description'=>$body . $attachment_html,<br />
            			'mt_allow_comments'=>1,<br />
            			'mt_allow_pings'=>1<br />
            			},<br />
            			1<br />
			)<br />
			->result;       <br />
                }<br />
                <br />
                if ($print_output)<br />
                {<br />
                    print "Message To: $to\n";<br />
                    print "Message From $from\n";<br />
          			print "Message Subject $subject\n";<br />
    				print "Message Body $body\n";<br />
    				print "Message Attachment $attachment\n";<br />
                    print "--------------------------\n";<br />
                }<br />
            <br />
            	if ($delete_messages)<br />
            	{<br />
	                $pop->delete($msgnum);<br />
	            }</p>

<p>        		if ($delete_temp_files)<br />
        		{	<br />
	    	    	$parser->filer->purge;<br />
	    		}<br />
	    		<br />
    	    $messagenum++;<br />
        }</p>

<p>}<br />
$pop->quit;</p>]]>

</content>
</entry>
<entry>
<title>class05</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/02/class06.html" />
<modified>2005-03-07T20:50:19Z</modified>
<issued>2005-03-01T00:53:03Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.177</id>
<created>2005-03-01T00:53:03Z</created>
<summary type="text/plain">i am sooooo confused!?!! rlelation of primary key one to many versus many to many. there seems to be a inherant way to organized I guess which i understand which might be different to the way people are explaining. jeff...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>i am sooooo confused!?!!</p>

<p>rlelation of primary key one to many versus many to many.</p>

<p>there seems to be a inherant way to organized I guess which i understand which might be different to the way people are explaining.</p>

<p>jeff versus matty, seans stuff?</p>

<p>missed the linking tabls? I am not sure if I need them but I did not have them.</p>

<p><br />
<u><strong>run commands through mysql command first then add to perl!</strong></u></p>

<p>info.pl chmod 600</p>

<p><br />
<strong></p>

<p>Always</p>

<p>#######<br />
#connect to db<br />
#####</p>

<p>blah blah</p>

<p><br />
######<br />
#disconnect<br />
######</strong></p>

<p><br />
<u>do command everything but select!</></p>

<p><br />
</p>]]>
<![CDATA[<p>Class 5 - Perl Talks to MySQL: The Web to the Database and Back</p>

<p>The Perl Interface To MySQL<br />
So now that we know how variables that are sent by the web browser can be manipulated by Perl, and how we can set up our database to store and manipulate these values, we need to connect Perl to the database. The interface of Perl to MySQL is a two-level approach consisting of the following:</p>

<p>    * DBI (DataBase Interface): a generic interface for Perl<br />
    * DBD (DataBase Driver): database-specific interface that talks to the Perl DBI </p>

<p>Thus, when Perl sends a SQL query to MySQL, the query is sent via the DBI to the DBD that is specific to MySQL. MySQL performs the query and sends the results back through its DBD to Perl's DBL interface such that Perl can obtains the results of the query. Visually, the chain is:</p>

<p>Perl -> DBI -> DBD for MySQL -> MySQL -> DBD for MySQL -> DBI -> Perl</p>

<p>Practical Considerations on Stage<br />
In order to connect to your MySQL database via Perl, you need to use your MySQL login and password that was assigned to you. Because this is sensitive information, you should keep it in its own separate script that is only readable and writable by you (i.e. permissions set to "-rw-------" or "600" instead of "-rwxr-xr-x" or "755"). I named mine "info.pl" and it looks something like this:</p>

<p>#########################################################<br />
# info.pl<br />
#########################################################</p>

<p>$mySqlUsername = "your MySQL username - usually your Net ID";<br />
$mySqlPassword = "your MySQL password";</p>

<p>1;</p>

<p>Then, you can reference this information at any time by issuing the statement:</p>

<p># Get Login Info<br />
require "info.pl";</p>

<p>However, in some environments, you may need to make sure that your main script can find the location of your login info script, so you can use the following to derive the the full directory path to your main script. The result is put in the var "$execDir":</p>

<p>if    ($0=~m#^(.*)\\#){ $execDir = "$1"; }  # Win/DOS<br />
elsif ($0=~m#^(.*)/# ){ $execDir = "$1"; }  # Unix<br />
else  {`pwd` =~ /(.*)/; $execDir = "$1"; }  # Unix</p>

<p>If you put your login info script in the same directory as your main script, then you know the exact location of your login info script and can reference by its full pathname like this:</p>

<p># Get Login Info<br />
require "$execDir/info.pl";</p>

<p>Common Perl DBI Methods<br />
You can achieve a lot with only a few commands using the Perl DBI. The main things to keep in mind are that you need to be able to connect to your database, you need to be able to make SQL queries, and you need to be able to disconnect. You connect to the DB once and only once at the beginning of your script, and you disconnect once and only once at the end of your script.</p>

<p>connect<br />
Establishes a database connection, or session, to the requested $data_source. Returns a database handle object if the connection succeeds. Use $dbh->disconnect to terminate the connection.</p>

<p>$dbh = DBI->connect($data_source, $username, $password);</p>

<p>Examples of $data_source values are:</p>

<p>dbi:DriverName:database_name<br />
dbi:DriverName:database_name@hostname:port<br />
dbi:DriverName:database=database_name;host=hostname;port=port</p>

<p>In the real world, the connection goes something like this:</p>

<p>use DBI();</p>

<p>$database = $mySqlUsername;<br />
$data_source = "dbi:mysql:$database";<br />
$username = $mySqlUsername;<br />
$password = $mySqlPassword;</p>

<p>#########################################################<br />
# Connect to the database.<br />
#########################################################<br />
# This only needs to be done once per script<br />
my $dbh = DBI->connect($data_source, $username, $password,<br />
	{'RaiseError' => 1, 'PrintError' => 1});</p>

<p> <br />
disconnect<br />
Disconnects the database from the database handle. disconnect is typically only used before exiting the program.</p>

<p>#########################################################<br />
# Disconnect from the database.<br />
#########################################################<br />
# Always the last thing you do before exiting your script<br />
$dbh->disconnect();</p>

<p>exit(0);</p>

<p> <br />
do<br />
The do method is used to prepare, execute, and finish a single statement. It returns the number of rows affected or undef on error. A return value of -1 means the number of rows is not known, not applicable, or not available.</p>

<p>$rows = $dbh->do($statement)</p>

<p>my $rows_deleted = $dbh->do('DELETE FROM table WHERE status = ?')<br />
	or die $dbh->errstr;</p>

<p>The main things about "do" is that it is great for INSERT, UPDATE, and DELETE queries but not for SELECT queries. More on that later. Here's some real world examples of "do":</p>

<p>#########################################################<br />
# Inserting<br />
#########################################################<br />
$myName = "Morgan";<br />
$myName = &escape_quotes($myName);<br />
$SqlStatement = "INSERT INTO class05_table1 (name) ";<br />
$SqlStatement .= "VALUES ('$myName') ";<br />
$affected_rows = $dbh->do($SqlStatement);</p>

<p>#########################################################<br />
# Updating<br />
#########################################################<br />
$myName = "Nancy";<br />
$myName = &escape_quotes($myName);<br />
$SqlStatement = "UPDATE class05_table1 ";<br />
$SqlStatement .= "SET name='$myName' ";<br />
$SqlStatement .= "WHERE id=1 ";<br />
$affected_rows = $dbh->do($SqlStatement);</p>

<p>#########################################################<br />
# Deleting<br />
#########################################################<br />
$myName = "Morgan";<br />
$myName = &escape_quotes($myName);<br />
$SqlStatement = "DELETE FROM class05_table1 ";<br />
$SqlStatement .= "WHERE name='$myName' ";<br />
$affected_rows = $dbh->do($SqlStatement);</p>

<p>Note that there is very little difference in how you make INSERT, UPDATE, and DELETE statements using the "do" method. It's all in how you construct the string that holds the actual SQL statement. In the above examples, we have put this statement into the scalar "$SqlStatement".</p>

<p> <br />
prepare, execute, finish<br />
The reality is that "do" is an alias for executing the above three methods and in that order. "Prepare" takes a SQL statement and hands it to the DBD for pre-processing. Once the statement has been "prepared", a statement handle is returned. This handle has a method called "execute" which actual performs the query and returns a result set. Once we are done with this result set, the "finish" method is called to tidy up memory and system resources.</p>

<p>$SqlStatement = "SELECT * FROM class05_table1";<br />
$sth = $dbh->prepare($SqlStatement);<br />
$sth->execute();</p>

<p># This is where we would obtain the results of our query</p>

<p>$sth->finish();</p>

<p>However, because "do" calls all three methods in a row, we don't ever get access to our result set because "do" has already called "finish", which has relinquished the very results in which we were interested. Thus, you have to explicitly "prepare" your SQL statement, then "execute" it, then obtain your result set using the two methods outlined below, and then "finish" it.</p>

<p> <br />
fetchrow_array<br />
The method "fetchrow_array" returns a normal array that contains all the values for the fields requested. It returns one row at a time. We can use the while loop structure in Perl to obtain all the rows from this query.</p>

<p>#########################################################<br />
# SELECT using fetchrow_array()<br />
#  Array containing one row of resultset<br />
#########################################################<br />
# $SqlStatement = "SELECT * FROM class05_table1";	# We can use wildcards to get all fields<br />
$SqlStatement = "SELECT id, name FROM class05_table1";	# Or explicitly label fields<br />
$sth = $dbh->prepare($SqlStatement);<br />
$sth->execute();<br />
while (@row_array = $sth->fetchrow_array())<br />
{	$current_id = $row_array[0];<br />
	$current_name = $row_array[1];<br />
}<br />
$sth->finish();</p>

<p>Note that the columns in your request match up with the indexes in your array in the order that you request them. Thus, "id" is at index 0 in your array, "name" is at index 1. If our select statement had been:</p>

<p>$SqlStatement = "SELECT name, id FROM class05_table1";</p>

<p>then "name" would be at index 0 in your array, and "id" would be at index 1. Here is a variety of examples that manipulate a table of user firstnames.</p>]]>
</content>
</entry>
<entry>
<title>class 04</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/02/class_04.html" />
<modified>2005-02-14T22:56:50Z</modified>
<issued>2005-02-14T20:35:28Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.150</id>
<created>2005-02-14T20:35:28Z</created>
<summary type="text/plain">relationship between tables null values to enter no information which once can add at a later time. Now that we have a basic understanding of how to create a simple table, we need to develop a better understanding of how...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>relationship between tables</p>

<p>null values to enter no information which once can add at a later time.</p>

<p>Now that we have a basic understanding of how to create a simple table, we need to develop a better understanding of how to separate our data into a particular configuration of tables. Database design has evolved to the point where there are specific steps you can take to optimize any database configuration. This process is called <strong>normalization</strong> and it has three distinct forms.</p>

<p>forms on normalization found on <a href="http://stage.itp.nyu.edu/~cs220/dwd/class04.html">class notes</a></p>

<p>removing further redundancy deals with many to many relationship tables.</p>

<p><br />
<strong>Multiple Table Joins</strong><br />
The whole point of having a relational database is to be able to connect two or more different tables such that we can extract various sets of data. The process of pulling data from two or more related tables is called a join. The most common is the inner join which has two different syntaxes. For our purposes, we will be using the older syntax, which is a bit easier to read. This format is:</p>

<p>SELECT [DISTINCT] column1[,column2]<br />
FROM table1,table2[,table3]<br />
[WHERE "conditions"]<br />
[GROUP BY "column-list" [ASC | DESC] ]<br />
[HAVING "conditions]<br />
[ORDER BY "column-list" [ASC | DESC] ]<br />
[LIMIT [offset,] number-rows]</p>

<p><em>see extended text to see working function</em></p>]]>
<![CDATA[<p>For class note:<br />
SELECT m.firstname,m.lastname,c.name<br />
FROM music101_musician m, music101_country c<br />
WHERE m.birth_country_id = c.id</p>

<p><br />
For puffles and types:<br />
SELECT p.name, m.type<br />
FROM media_types m, puffles p<br />
WHERE m.id = p.type<br />
<b>DATE_FORMAT(date,format)</b><br />
Formats the date value according to the format string. The<br />
following specifiers may be used in the format string:<br />
<p><br />
<table cellspacing="0" cellpadding="3" border="1"><br />
<TR><td><font face="verdana" size="2"><strong>Specifier</strong> </TD><td><font face="verdana" size="2"> <strong>Description</strong><br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%M </TD><td><font face="verdana" size="2"> Month name (January..December)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%W </TD><td><font face="verdana" size="2"> Weekday name (Sunday..Saturday)</p>

<p></TD></TR><br />
<TR><td><font face="verdana" size="2">%D </TD><td><font face="verdana" size="2"> Day of the month with English suffix (0th, 1st, 2nd, 3rd, etc.)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%Y </TD><td><font face="verdana" size="2"> Year, numeric, 4 digits<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%y </TD><td><font face="verdana" size="2"> Year, numeric, 2 digits<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%X </TD><td><font face="verdana" size="2"> Year for the week where Sunday is the first day of the week, numeric, 4 digits; used with %V<br />
</TD></TR></p>

<p><TR><td><font face="verdana" size="2">%x </TD><td><font face="verdana" size="2"> Year for the week, where Monday is the first day of the week, numeric, 4 digits; used with %v<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%a </TD><td><font face="verdana" size="2"> Abbreviated weekday name (Sun..Sat)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%d </TD><td><font face="verdana" size="2"> Day of the month, numeric (00..31)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%e </TD><td><font face="verdana" size="2"> Day of the month, numeric (0..31)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%m </TD><td><font face="verdana" size="2"> Month, numeric (00..12)</p>

<p></TD></TR><br />
<TR><td><font face="verdana" size="2">%c </TD><td><font face="verdana" size="2"> Month, numeric (0..12)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%b </TD><td><font face="verdana" size="2"> Abbreviated month name (Jan..Dec)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%j </TD><td><font face="verdana" size="2"> Day of year (001..366)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%H </TD><td><font face="verdana" size="2"> Hour (00..23)<br />
</TD></TR></p>

<p><TR><td><font face="verdana" size="2">%k </TD><td><font face="verdana" size="2"> Hour (0..23)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%h </TD><td><font face="verdana" size="2"> Hour (01..12)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%I </TD><td><font face="verdana" size="2"> Hour (01..12)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%l </TD><td><font face="verdana" size="2"> Hour (1..12)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%i </TD><td><font face="verdana" size="2"> Minutes, numeric (00..59)</p>

<p></TD></TR><br />
<TR><td><font face="verdana" size="2">%r </TD><td><font face="verdana" size="2"> Time, 12-hour (hh:mm:ss followed by AM or PM)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%T </TD><td><font face="verdana" size="2"> Time, 24-hour (hh:mm:ss)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%S </TD><td><font face="verdana" size="2"> Seconds (00..59)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%s </TD><td><font face="verdana" size="2"> Seconds (00..59)<br />
</TD></TR></p>

<p><TR><td><font face="verdana" size="2">%f </TD><td><font face="verdana" size="2"> Microseconds (000000..999999)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%p </TD><td><font face="verdana" size="2"> AM or PM<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%w </TD><td><font face="verdana" size="2"> Day of the week (0=Sunday..6=Saturday)<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%U </TD><td><font face="verdana" size="2"> Week (00..53), where Sunday is the first day of the week<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%u </TD><td><font face="verdana" size="2"> Week (00..53), where Monday is the first day of the week</p>

<p></TD></TR><br />
<TR><td><font face="verdana" size="2">%V </TD><td><font face="verdana" size="2"> Week (01..53), where Sunday is the first day of the week; used with %X<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%v </TD><td><font face="verdana" size="2"> Week (01..53), where Monday is the first day of the week; used with %x<br />
</TD></TR><br />
<TR><td><font face="verdana" size="2">%% </TD><td><font face="verdana" size="2"> A literal <samp>`%'</samp>.<br />
</TD></TR><br />
</TABLE><br />
<p></p>]]>
</content>
</entry>
<entry>
<title>assignment 3</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/02/assignment_3.html" />
<modified>2005-02-14T08:05:35Z</modified>
<issued>2005-02-14T08:04:59Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.149</id>
<created>2005-02-14T08:04:59Z</created>
<summary type="text/plain">#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); # Define the name of the script just for reference $scriptName = &quot;mysql.cgi&quot;; # Tell the browser what type of data to expect print &quot;Content-type: text/html\n\n&quot;; ######################################################### # Print HTML ######################################################### print qq^ &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt; MySQL Images...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Writen Code</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>#!/usr/bin/perl</p>

<p>use CGI::Carp qw(fatalsToBrowser);</p>

<p># Define the name of the script just for reference<br />
$scriptName = "mysql.cgi";</p>

<p></p>

<p># Tell the browser what type of data to expect<br />
 print "Content-type: text/html\n\n";</p>

<p>#########################################################<br />
# Print HTML<br />
#########################################################<br />
print qq^<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<br />
"http://www.w3.org/TR/html4/loose.dtd"><br />
<html><br />
<head><br />
<title>MySQL Images</title><br />
<style type="text/css"><br />
<!--<br />
.style1 {<br />
	font-family: Arial, Helvetica, sans-serif;<br />
	font-weight: bold;<br />
	color: #CCCCCC;<br />
}<br />
body {<br />
	background-color: #333333;<br />
}<br />
--><br />
</style><br />
</head></p>

<p><body><br />
<p><span class="style1">This is the structure for the database Puffles: </span><br><br />
  <img src="pdb/DB_structures.jpg" width="799" height="440"><br><br />
    <span class="style1">PrePopulation:</span><br><br />
  <img src="pdb/prepopulated.jpg" width="548" height="362"><br />
</p><br />
<p class="style1">'at the beach' added:<br><br />
<img src="pdb/added_item_6.jpg" width="541" height="481"></p><br />
<p class="style1">Select command used to find entries older then 2004/04/11:<br><br />
  <img src="pdb/command_date_select.jpg" width="543" height="289"></p><br />
<p class="style1">Results from select command:<br><br />
  <img src="pdb/command_select_return.jpg" width="462" height="521"></p><br />
<p class="style1">Command update:<br> <br />
<img src="pdb/command_update_more.jpg" width="438" height="396"></p><br />
<p class="style1">Delete Command:<br><br />
<img src="command_delete.jpg" width="428" height="379"></p><br />
<p class="style1">Final Population:<br><br />
<img src="pdb/final_population.jpg" width="510" height="444"></p><br />
</body><br />
</html></p>

<p>^;</p>

<p><br />
exit;</p>]]>

</content>
</entry>
<entry>
<title>class 03</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/02/class_03.html" />
<modified>2005-02-07T22:18:09Z</modified>
<issued>2005-02-07T20:24:05Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.134</id>
<created>2005-02-07T20:24:05Z</created>
<summary type="text/plain">missed class 2... &quot;\&quot; escapes a command in perl. so if you want to use character like $ @ ETC... don&apos;t escape and it will &quot;BARF&quot; subroutine for perl to receive form in for from html: ################################################ # Takes data...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>missed class 2...</p>

<p>"\" escapes a command in perl. so if you want to use character like $ @ ETC...</p>

<p>don't escape and it will "BARF"</p>

<p>subroutine for perl to receive form in for from html:</p>

<p><br />
<strong>################################################<br />
# Takes data from an HTML Form or URL string<br />
################################################<br />
sub input_vars_receive<br />
{ $formData = $ENV{'QUERY_STRING'};</p>

<p>	if ($ENV{'REQUEST_METHOD'} eq 'POST')<br />
	{	read(STDIN, $formData, $ENV{'CONTENT_LENGTH'});<br />
	}<br />
</strong></p>

<p>this code allows people post or use the browser line.</p>

<p><br />
persistance:<br />
rewrites to  the text field. if you dont the text field will return clear...</p>

<p>fix text</p>

<p>redo code</p>

<p>environment tags...</p>

<p><strong>MySQL</strong><br />
<a href="http://stage.itp.nyu.edu/~cs220/dwd/class03.html">chris' class note's</a></p>

<p>relational database</p>

<p>Tableis made up of:<br />
columns: fields<br />
rows: entries</p>

<p>if a field set is constant one can create a new table to be called into other table.<br />
<em>one to many relationship</em> Like a book one book many pages, birth place, </p>

<p><em>Many to many relationship</em> for example an album can thought of a part of many styles, can be called a linking table.</p>

<p><strong>" ' "</strong> is MySQL's  escape character command</p>

<p>insert add<br />
update change</p>

<p>"LIKE"</p>]]>
<![CDATA[<p>#</p>

<p>Week 3: Database Design, MySQL, and the SQL Language - Part 1</p>

<p>Topics:<br />
# Introduction to Databases<br />
# Relationship Modeling<br />
# Using PhpMyAdmin To Create Your First Table<br />
# MySQL Data Types<br />
# Basic SQL Commands</p>

<p>Resources:<br />
# Class #3 Notes<br />
# PhpMyAdmin Database Tool</p>

<p>Weekly Assignment:<br />
The basis of this week's assignment is to create and manipulate a table of your own creation, but also to show what you did and present it in a web page that is created by a Perl script. Thus, all SQL statements that you issue will be documented in your web page, as well as how each statement affected the data in your table. Here are more specific instructions:</p>

<p>    * Create a table of your choosing which contains the following columns: an ID column, at least one numeric column (i.e. integer, double, or decimal), at least one string column (i.e. varchar, text, or blob), and at least one date or time column (i.e. date, time, datetime, etc). Show a visual representation of the columns of your table in your Perl-generated web page. You can use the "Print View" link on the PhpMyAdmin "Structure" page and take a snapshot of your table in PhotoShop and present it as an image, or you can cut and paste the HTML from the "Print View" link into your Perl script, or use whatever means necessary to show the structure of your table inside of your Perl-generated web page.<br />
    * Using the INSERT statement in the PhpMyAdmin SQL window, create at least 5 records.<br />
    * Inside of your Perl-generated web page, list the INSERT statements that were used to create your data set. Then show all records in your table. You can use the "Print View" link on the PhpMyAdmin "Browse" page and take a snapshot of your table in PhotoShop and present it as an image, or you can cut and paste the HTML from the "Print View" link into your Perl script, or use whatever means necessary to show the contents of your table inside of your Perl-generated web page.<br />
    * Using the SELECT statement in the PhpMyAdmin SQL window, make at three targeted queries. One should be based upon a numeric column (i.e. where id=5), one should be based upon a text query (i.e. where name='Jones') and one should be based upon a datetime column (i.e. where date>'4/1/2001'). Show each query and its respective results inside of your Perl-generated web page.<br />
    * Using the UPDATE statement in the PhpMyAdmin SQL window, change at least one of the records in your table. Show the statement and the new contents of your table inside of your Perl-generated web page.<br />
    * Using the DELETE statement in the PhpMyAdmin SQL window, remove at least one but not all of the records in your table. Show the statement and the new contents of your table inside of your Perl-generated web page. </p>

<p>Please try to choose your table columns and queries in some sort of coherent fashion. Think of some data in your life that you'd like to organize (address book, the weather, your CDs, etc), and how you might be able to keep track of it, and to obtain interesting results by querying it.</p>

<p>Recommended Reading/Reference:<br />
# Teach Yourself MySQL in 21 Days By Anthony Butcher<br />
Pages 42-46 (Relationship Modeling), 65-83 (Data Types), 109-112 (INSERT), 115-116 (UPDATE), 128-134 (SELECT), 151 (DELETE)</p>]]>
</content>
</entry>
<entry>
<title>Assignment 2</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/02/assignment_2.html" />
<modified>2005-02-07T22:06:06Z</modified>
<issued>2005-02-07T15:03:54Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.133</id>
<created>2005-02-07T15:03:54Z</created>
<summary type="text/plain">Since I missed class, this is more my style of who I would do it, using the example code. test.cgi Code is in read more...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Writen Code</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>Since I missed class, this is more my style of who I would do it, using the example code.</p>

<p><a href="http://dimitri.negroponte.com/blog/dweb/test.cgi">test.cgi</a></p>

<p>Code is in read more</p>]]>
<![CDATA[<p><strong>This is the cgi:</strong></p>

<p>#!/usr/bin/perl</p>

<p>#########################################################<br />
# class02-file1.pl - Basic File I/O<br />
#########################################################<br />
# Use CGI Perl module to output any error msgs to browser<br />
use CGI::Carp qw(fatalsToBrowser);</p>

<p># Define the name of the script just for reference<br />
$scriptName = "test.cgi";<br />
$pageTitle = "thoughts";</p>

<p># Obtain any variables submitted either in the URL string<br />
#  or by an HTML form via the GET or POST method, and<br />
#  place in the %INPUT_VARS hash array<br />
%INPUT_VARS = {};<br />
&input_vars_receive;<br />
&input_vars_parse;</p>

<p>#########################################################<br />
# Define which file we will be using on the server<br />
#########################################################<br />
$myFile = "/home/dimitri/public_html/blog/dweb/file1.txt";</p>

<p>#########################################################<br />
# Define our widgets here and collect values from INPUT_VARS array<br />
#########################################################<br />
$textWidgetLabel = "Penny for a thought:";<br />
$textWidgetName = "Thought";<br />
$textWidgetValue = $INPUT_VARS{$textWidgetName};</p>

<p>$submitWidgetName = "dataAction";<br />
$submitWidgetValue = "Enter";</p>

<p>$commentWasSubmitted = 0;</p>

<p>#########################################################<br />
# Check our inputs and perform any file content updates<br />
#########################################################<br />
if ($INPUT_VARS{$submitWidgetName} eq "$submitWidgetValue")<br />
{	# Form was submitted so check if the comment field actually had text<br />
	if ($textWidgetValue ne "")<br />
	{	# This is how you write text to a file in Perl<br />
		open INPTR, ">>$myFile";<br />
		print INPTR "<p class=\"style1\">";<br />
		print INPTR "$textWidgetValue\n";<br />
		print INPTR "</p>";<br />
		close INPTR;<br />
		<br />
		# Set a flag so that we know that we actually had a valid comment<br />
		$commentWasSubmitted = 1;<br />
	}<br />
}</p>

<p># Tell the browser what type of data to expect<br />
print "Content-type: text/html\n\n";</p>

<p>#########################################################<br />
# Print our initial HTML<br />
#########################################################<br />
print qq^<br />
<html><br />
<head><br />
<title>$pageTitle</title><br />
</head><br />
<style type="text/css"><br />
<!--<br />
.style1 {<br />
	font-family: Arial, Helvetica, sans-serif;<br />
	font-weight: bold;<br />
}<br />
body,td,th {<br />
	font-family: Arial, Helvetica, sans-serif;<br />
}<br />
a:link {<br />
	color: #003399;<br />
	text-decoration: none;<br />
}<br />
a:visited {<br />
	text-decoration: none;<br />
	color: #333333;<br />
}<br />
a:hover {<br />
	text-decoration: none;<br />
	color: #000000;<br />
}<br />
a:active {<br />
	text-decoration: none;<br />
	color: #333333;<br />
}<br />
--><br />
</style></p>

<p>^;</p>

<p></p>

<p></p>

<p><br />
print qq^<br />
<div align="center"><br />
<table border=0 cellpadding=5 cellspacing=5 width=65%><br />
<tr><br />
	<td valign="top"><br />
	<form action="$scriptName" method="POST" enctype="application/x-www-form-urlencoded"><br />
	<font face="verdana, arial" size="2"><br />
	<font size="3"><b>$pageTitle</b></font><br />
	<p><br />
	Using the code from the class notes I built a entery page which sends the text to a file. There is then a SHTML page which uses "SSI" to read the text in. I understand the basic concept, but because I missed class there are somethings I am not quite sure about.<br />
	<p><br />
$textWidgetLabel<br />
<input type=text name="$textWidgetName" value="" size="40" maxlength="255"><br />
<input type="submit" name="$submitWidgetName" value="$submitWidgetValue"><br />
</form><br />
</font></td><br />
</tr><br />
</table><br />
^;</p>

<p># Give the user feedback if they submitted something<br />
if ($commentWasSubmitted==1)<br />
{	print qq^<table border=0 cellpadding=5 cellspacing=5 width=65%><br />
<tr><br />
	<td valign="top"><br />
	<font face="verdana, arial" size="2" color="#990000"><b>Its good to think!</b><br />
	</font></td><br />
</tr><br />
<tr><br />
<td><br />
<a href="thoughts.shtml"><em>read the thoughts</em></a></td><br />
</tr><br />
</table><br />
^;<br />
}</p>

<p>print qq^<br />
</body><br />
</html>^;</p>

<p>exit;</p>

<p>#########################################################<br />
# Takes data from an HTML Form or URL string<br />
#########################################################<br />
sub input_vars_receive<br />
{ $formData = $ENV{'QUERY_STRING'};</p>

<p>	if ($ENV{'REQUEST_METHOD'} eq 'POST')<br />
	{	read(STDIN, $formData, $ENV{'CONTENT_LENGTH'});<br />
	}<br />
}</p>

<p>#########################################################<br />
# Parses form info<br />
#########################################################<br />
sub input_vars_parse<br />
{	local($name,$value,$pair);<br />
	local(@pairs) = split(/&/, $formData);</p>

<p>	# Get parameter names, their values and copy into $INPUT_VARS array<br />
	foreach $pair (@pairs)<br />
	{	($name,$value)=split(/=/,$pair);<br />
		$value=~tr/+/ /s;<br />
		$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;<br />
		$INPUT_VARS{$name}=$value;<br />
	}<br />
}</p>

<p><br />
______________________________________________________________________</p>

<p><strong>This is the shtml:</strong></p>

<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<br />
"http://www.w3.org/TR/html4/loose.dtd"><br />
<html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
<title>Thoughts</title><br />
<style type="text/css"><br />
<!--<br />
.style1 {<br />
	font-family: Arial, Helvetica, sans-serif;<br />
	font-weight: bold;<br />
}<br />
body,td,th {<br />
	font-family: Arial, Helvetica, sans-serif;<br />
}<br />
a:link {<br />
	color: #003399;<br />
	text-decoration: none;<br />
}<br />
a:visited {<br />
	text-decoration: none;<br />
	color: #333333;<br />
}<br />
a:hover {<br />
	text-decoration: none;<br />
	color: #000000;<br />
}<br />
a:active {<br />
	text-decoration: none;<br />
	color: #333333;<br />
}<br />
.style2 {font-family: Arial, Helvetica, sans-serif}<br />
--><br />
</style><br />
</head></p>

<p><body></p>

<div align="center">
  <table width="401" border="0">
    <tr>
      <td><div align="center">Take a thought and if you have one leave it <br>
        <br>
      </div></td>
    </tr>
    <tr>
      <td>
        <!--#include virtual="file1.txt" -->
  </td>
    </tr>
    <tr>
      <td><div align="center"><a href="test.cgi" class="style2"><em>Add a new thought</em></a> </div></td>
    </tr>
  </table>
</div>
</body>
</html>
]]>
</content>
</entry>
<entry>
<title>Assignment 1</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/01/assignment_1.html" />
<modified>2005-01-29T04:47:26Z</modified>
<issued>2005-01-29T04:43:43Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.106</id>
<created>2005-01-29T04:43:43Z</created>
<summary type="text/plain">I wrote about flickr&apos;s tags. Mind you my server is set up to read perl scripts as .cgi http://dimitri.negroponte.com/blog/dweb/dynamic.cgi The code is in read more....</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Writen Code</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>I wrote about flickr's tags.</p>

<p>Mind you my server is set up to read perl scripts as .cgi</p>

<p><a href="http://dimitri.negroponte.com/blog/dweb/dynamic.cgi">http://dimitri.negroponte.com/blog/dweb/dynamic.cgi</a></p>

<p>The code is in read more.</p>]]>
<![CDATA[<p>#!/usr/bin/perl</p>

<p># Use CGI Perl module to output any error msgs to browser<br />
#use CGI::Carp qw(fatalsToBrowser);</p>

<p># Tell the browser what type of data to expect<br />
print "Content-type: text/html\n\n";</p>

<p># Print our initial HTML<br />
print qq^<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<br />
"http://www.w3.org/TR/html4/loose.dtd"><br />
<html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
<title>Untitled Document</title><br />
<style type="text/css"><br />
<!--<br />
.style1 {font-family: Arial, Helvetica, sans-serif}<br />
--><br />
</style><br />
</head></p>

<p><body><br />
<p align="center">&nbsp;</p><br />
<div align="center"><br />
  <table width="478" border="0"><br />
    <tr><br />
      <td width="468"><p align="justify" class="style1">While I am not a fan of flickr, there is one thing I like on the site, tags. mind you my problems is that I rather have the images to work with my own way. Being that I am interested in design and a photographer, I like to do things myself. Back to the manner at hand, tags.</p><br />
      <p align="justify" class="style1">Tags are an interesting visual for a dynamic website. It shows the change of information on the site. Today dynamic sites have lots of information and show you what you want but they rarely show you a globe view of all the information. Tags does this. Many other photo site show what users of the site by making a gallery of best pictures or news ones. By grabbing the tagline of each image, it sizes the word used in the tagline and creates visual fabric of text.</p></td><br />
    </tr><br />
    <tr><br />
      <td><div align="center"><a href="http://www.flickr.com/photos/tags">Tags</a></div></td><br />
    </tr><br />
  </table><br />
</div><br />
<p align="center">&nbsp;</p><br />
</body><br />
</html><br />
^;</p>

<p>exit;</p>]]>
</content>
</entry>
<entry>
<title>Perl error</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/01/perl_error.html" />
<modified>2005-01-24T23:33:49Z</modified>
<issued>2005-01-24T22:15:48Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.98</id>
<created>2005-01-24T22:15:48Z</created>
<summary type="text/plain">CGI::Carp module for perl tells what the problem is in the html error message. use CGI::Carp...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>CGI::Carp module for perl tells what the problem is in the html error message.</p>

<p>use CGI::Carp</p>]]>

</content>
</entry>
<entry>
<title>Resources</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/01/resources.html" />
<modified>2005-01-27T04:32:19Z</modified>
<issued>2005-01-24T21:24:23Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.97</id>
<created>2005-01-24T21:24:23Z</created>
<summary type="text/plain"> Useful Resources Class Listserv itpdb @ forums dot nyu dot edu Perl Books Learning Perl By Randal L. Schwartz, Tom Phoenix (recommended) Programming Perl By Larry Wall, Tom Christiansen, Jon Orwant On-Line Perl Reference Perl Programming FAQ Rex Swain&apos;s...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Resources</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p><TABLE WIDTH="100%" BORDER="0" CELLPADDING="10" CELLSPACING="0"><br />
<TR><br />
	<td valign="top" align="left"><br />
	<font face="verdana, arial" size="2" class="m2"><br />
<font size="3"><b>Useful Resources</b></font><br />
<b>Class Listserv</b><br><br />
<li> itpdb @ forums dot nyu dot edu<br><br />
<p><br />
<b>Perl Books</b><br><br />
<li> <a target="newPage" href="http://www.oreilly.com/catalog/lperl3/">Learning Perl</a> By Randal L. Schwartz, Tom Phoenix (recommended)<br></p>

<p><li> <a target="newPage" href="http://www.oreilly.com/catalog/pperl3/">Programming Perl</a> By Larry Wall, Tom Christiansen, Jon Orwant<br />
<p><br />
<b>On-Line Perl Reference</b><br><br />
<li> <a target="newPage" href="http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq.html">Perl Programming FAQ</a> <br><br />
<li> <a target="newPage" href="http://www.rexswain.com/perl5.html">Rex Swain's HTMLified<br />
Perl 5 Reference Guide</a><br><br />
<li> <a target="newPage" href="http://www.perl.com/pub/q/documentation">O-Reilly Perl On-Line Documentation</a></p>

<p><li> <a target="newPage" href="http://search.cpan.org/author/TIMB/DBI-1.37/DBI.pm">Perl DBI Documentation</a><br />
<p><br />
<b>Perl Modules</b><br><br />
<li> <a target="newPage" href="http://www.cpan.org/modules/index.html">Perl Modules at CPAN.org</a> <br><br />
<li> <a target="newPage" href="http://www.cpan.org/misc/cpan-faq.html">CPAN Frequently Asked Questions</a><br />
<p><br />
<b>MySQL Reference</b><br><br />
<li> <a target="newPage" href="http://www.amazon.com/exec/obidos/tg/detail/-/0672323923/">Teach Yourself MySQL in 21 Days</a> By Anthony Butcher <br></p>

<p><li> <a target="newPage" href="http://www.mysql.com/doc/en/GROUP-BY-Functions.html">MySQL GROUP BY Functions</a> <br><br />
<li> <a target="newPage" href="http://www.mysql.com/doc/en/Date_and_time_functions.html">MySQL Date and Time Functions</a> <br><br />
<li><a target="newPage" href="http://stage.itp.tsoa.nyu.edu/phpMyAdmin/">PhpMyAdmin Database Tool on Stage</a><br><br />
<li> <a target="newPage" href="http://www.fabforce.net/dbdesigner4/">DBDesigner 4</a> <br><br />
<p><br />
<b>HTML Reference</b><br></p>

<p><li> <a target="newPage" href="http://www.webmonkey.com">WebMonkey.com</a><br />
<p><br />
<b>JavaScript Reference</b><br><br />
<li><a target="newPage" href="http://hotwired.lycos.com/webmonkey/programming/javascript/tutorials/tutorial1.html">Thau's JavaScript Tutorial</a> at WebMonkey.com <br><br />
<p><br />
<b>Flash Reference</b><br><br />
<li> <a target="newPage" href="http://stage.itp.tsoa.nyu.edu/flash/">Interactivity in Flash Class Website</a><br><br />
<li> <a target="newPage" href="http://www.macromedia.com/devnet/mx/flash/">Flash Developer Center</a><br></p>

<p>
<b>Dissected Dynamic Websites</b><br>
<li> <a target="newPage" href="http://www.friendster.com/">Friendster.com</a><br>
<li> <a target="newPage" href="http://www.wholenote.com/">Wholenote.com</a><br>
<p>
	</td>
</tr>
</table>]]>

</content>
</entry>
<entry>
<title>notes 01</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/01/notes_01.html" />
<modified>2005-01-24T21:23:55Z</modified>
<issued>2005-01-24T20:26:11Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.96</id>
<created>2005-01-24T20:26:11Z</created>
<summary type="text/plain">Uses homesite... static vs dynamic in web-building music site to look at, WholeNote Bastardize version... because it is on the web... -Static -html -Script -perl -php -Scriptw/DB -perl with DB -php with DB looked at Wallop required reading: learning perl...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p>Uses homesite...</p>

<p>static vs dynamic in web-building</p>

<p><br />
music site to look at, <a href="http://www.wholenote.com">WholeNote</a></p>

<p>Bastardize version... because it is on the web...</p>

<p>-Static<br />
  -html<br />
-Script<br />
  -perl<br />
  -php<br />
-Scriptw/DB<br />
  -perl with DB<br />
  -php with DB</p>

<p><br />
looked at Wallop</p>

<p>required reading:</p>

<p>learning perl<br />
MySQL in 21 days</p>]]>

</content>
</entry>
<entry>
<title>class Info</title>
<link rel="alternate" type="text/html" href="http://dimitri.negroponte.com/blog/dweb/archives/2005/01/class_info.html" />
<modified>2005-01-24T20:26:03Z</modified>
<issued>2005-01-24T20:20:18Z</issued>
<id>tag:dimitri.negroponte.com,2005:/blog/dweb//8.95</id>
<created>2005-01-24T20:20:18Z</created>
<summary type="text/plain">Dynamic Web Development class info: Course Description How does one move away from creating static websites and toward building active, evolving hubs of activity? This class will cover the design and implementation of the &quot;dynamic&quot; website in two distinct but...</summary>
<author>
<name>dimitri</name>
<url>http://dimitri.negroponte.com/nucleus/</url>
<email>dimitri@media.mit.edu</email>
</author>
<dc:subject>Class Notes</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://dimitri.negroponte.com/blog/dweb/">
<![CDATA[<p><a href="http://itp.nyu.edu/~cs220/dwd/index.html">Dynamic Web Development</a></p>

<p>class info:</p>

<p><strong>Course Description</strong><br />
How does one move away from creating static websites and toward building active, evolving hubs of activity? This class will cover the design and implementation of the "dynamic" website in two distinct but related contexts: the technical aspects of manipulating content "on the fly", and the end user experience of interacting in this type of setting. Particular attention will be given to social and community-based web interaction. The production environment will consist of the MySQL database and the Perl programming language. Students can expect to develop a firm knowledge of database design and optimization, the SQL query language, and the use of Perl to create dynamic activity of both orthodox and unorthodox nature. Late-semester topics will focus on interfacing this environment with other technologies such as JavaScript and Flash, along with data population and site architecture methodology. Introduction to Computational Media or equivalent programming experience is required. Students are also expected to have fluency in HTML or to come up to speed with it outside of class. Class requirements will include homework assignments to reinforce each week's concepts while simultaneously contributing to the student's "toolkit" of code and design principles. There will also be a midterm project, and a final project of the student's choosing. Given the wide range of applications that would benefit from a web-accessible database, students should feel free to use their project(s) from this class to support or enhance projects from other classes.</p>

<p><strong>Syllabus</strong></p>

<p>   1. Introduction and Dynamic Website Theory Basics<br />
   2. Perl Basics and CGI: Script-Generated Pages<br />
   3. Database Design, MySQL, and the SQL Language - Part 1<br />
   4. Database Design, MySQL, and the SQL Language - Part 2<br />
   5. Perl Talks to MySQL: The Web to the Database and Back<br />
   6. Perl Tricks: The Basic and The Sexy<br />
   7. Dissection of a Dynamic Website: Friendster.com<br />
   8. Mid-Term Project Presentation<br />
   9. Dynamic Web Development on the Client-Side: JavaScript<br />
  10. More Client-Side: Interfacing with Flash<br />
  11. Dynamic Web Development and Scalability<br />
  12. Dissection of Dynamic Websites: DodgeBall, Wallop, WholeNote<br />
  13. Final Project Workshop<br />
  14. Final Project Presentation </p>

<p><strong>Teacher Biography</strong><br />
Christopher Sung (B.S., Yale; M.P.S., NYU) is the President and CEO of eTonal Media, Inc. which owns and operates the WholeNote.com website for guitarists, the ActiveBass.com website for bassists, and ActiveMusician.com, an on-line retail musician store. eTonal's sites have garnered attention from such publications as The New York Times, Guitar Player magazine, Acoustic Guitar magazine, and Bass Player magazine. Prior to founding eTonal in 1999, he spent stints at Yale's Center for Studies in Music Technology (CSMT), the Banff School of the Arts, MIT Lincoln Laboratory, the Berklee College of Music, Microsoft Research, Interval Research, and Organic. Christopher holds a US patent in the field of music technology, and is active in the New York music scene, playing guitar with ASCAP and MAC-award winners Marcy Heisler and Zina Goldrich in the realm of musical theater, and with the singer/songwriter Talia Paul in the pop/rock sphere.</p>]]>

</content>
</entry>

</feed>