Tuesday, 31 January 2012

I forgot to do something



Yeah, I told my client casually over dinner a week or so ago but I completely forgot to send an email to him confirming it

Monday, 30 January 2012

?

I am completely puzzled as to why this does not work...

<?php
$con = mysql_connect("localhost","admin");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  $PID=$_POST["fList"];
    $STDNTNAME=$_POST["fname"];
 $STDNTCMNT=$_POST["fcomments"];
 $TMSTMP=time();
$sql="INSERT INTO commenttable (PhotoID, StudentName, StudentComment, Date) VALUES
('$PID','$STDNTNAME','$STDNTCMNT','$TMSTMP')";
    mysql_query($sql); 
mysql_close($con)
?>

OH. I just remembered I forgot to select a database...I'll try that now

Odd...I cant connect

Forgot to mention a few things

I forgot to mention a few very important emails. One is from my Aunt Heidi, the free lance web programmer and her husband who does the same, the other is from my client.

Hi Laura,

Your Aunt asked me to have a look at your questions.

Well I don't see anything obviously wrong with what you've done, so I don't know why it isn't working.
Why don't you give this a whirl instead, it is from the horses' mouth as it were:


The result of going through that wizard should give you code to paste in.
I think if you normally refer people to 'http://hisfield.netau.net/' rather than 'http://www.histifle.dnetau.net/' then you should use that name for indexing also.

There are ways to prevent a site from being indexed, in particular a robots.txt file, but that isn't something that you would accidentally have created.  But for more information on that see http://www.robotstxt.org/robotstxt.html

Search engines usually use their own peculiar data stores rather than SQL databases.
Largely this is because, unlike an SQL database, they are intended to perform text searches and/or regular expression matches within text.
Tables in an SQL database are generally already parsed into 'columns' for particular types of data so they are more easily searched.
Sometimes some of the meta data may be stored in an RDBMS like MySQL.

The other big challenge for larger search engines is that they often involve indexing a huge amount of data.

Google, Bing etc have their own search engine and infrastructure, but there are also open source search engines which are based on 'full text search'.  One of the most popular such search engine is Apache Lucene, see:

and

But to run a site with back end services like this means you need access to and/or to install software on the host server itself, this may be problematic depending who and how your site is hosted.

I think from the description of your requirements google search should meet your needs if you can get it going, so I suggest you go through the wizard I pasted in at the top and let us know how that goes.

     Uncle David (& Aunt Heidi)


On Mon, Jan 23, 2012 at 12:05 PM, Heidi Cheung <heidi.s.cheung@gmail.com> wrote:
Dave, Can you help Laura, please? Thanks, Heidi
---------- Forwarded message ----------
From: laura cheung <laura001_hk@yahoo.com>
Date: Sun, Jan 22, 2012 at 12:05 AM
Subject: Re: Laura-question about Search Engines
To: Heidi Cheung <
heidi.s.cheung@gmail.com>

Oops sorry. wrong email.

From: laura cheung <laura001_hk@yahoo.com>
To: Heidi Cheung <
heidi.cheung@rogers.com>
Sent: Saturday, January 21, 2012 5:14 PM
Subject: Re: Laura-question about Search Engines

Dear Aunt Heidi,
Sorry to bother you once more but I would like to seek your advice once more.  The link you sent me previously
does not seem to be working on my dad's website (which i have recently uploaded due to my impatience despite not being finished yet) http://hisfield.netau.net/
When I search for things, nothing comes up.
 
I suspect that it is because google has not indexed my website therefore a google search engine will not work. I have tried to get Google to index my site by submitting the link to them but it still has not worked. Do you know how long it normally takes? Is it even related to my problem? I hand-coded on Notepad++, used 000webhost.com to host and Cushy CMS to add some content and make sure that my dad can easily edit.
 
I tried to build my own search engine using php and mysql but there were several problems i could not fix, therefore I had to resort to embedding such things :)
 
Thanks,
Laura
(i hope that the website comes out all right on your browser. I use internet explorer.)



Next, is the email from my client. I sent him an email last week, letting him try out the website a little
He particularly enjoyed Cushy CMS. I may have forgotten to mention this but, I signed up for CushyCMS. All I have to do is add the class "cushycms" to things and CushyCMS will allow the client to edit it.

INSERT INTO

So my code wont work and I dont know why...
So I tested every single part of it, the database connecting was easily tested with the if statement, the assignment of variables was tested by having it use PHP and variables to echo back what I had entered in the form. Next I tested the SQL. No problems. This image below involves the testing of the SQL of INSERT INTO. I created a separate database to test it out.

Thursday, 26 January 2012

Updates

I spent several days uploading photos to photobucket and inserting them into the code of the website.
Then I learnt about form processing here
http://www.html-form-guide.com/php-form/php-form-processing.html

and how to put dates into my mysql table here
http://www.plus2net.com/php_tutorial/php_date_time.php

Forget AJAX

Okay, turns out I DO NOT need AJAX. I took one look at it, got slightly intimidated and decided to do more research
http://www.hotscripts.com/forums/javascript/39278-php-inside-javascript.html
This says that I can simply do this...
<script>
function msg1(){alert("<?PHP echo $message1 ?>");}
function msg2(){alert("<?PHP echo $message2 ?>");}
function msg3(){alert("<?PHP echo $message3 ?>");}
function msg4(){alert("<?PHP echo $message4 ?>");}
</script>

Like just put "<?PHP ?>" tags into it. Well that simplifies things.

Wednesday, 25 January 2012

AJAX

So I was doing some work on the photo gallery today...I had no clue. I have a habit of thinking of things before I sleep, and these past few nights have been full of dreams about MySQL arrays and the possibilities. So today, I jotted down a couple of options I could take with the comments system.

So I went with option 2-which I titled "Hard, but not as tedious". But first I needed to make a huge drop down list for the comments form. now THAT seemed tedious. I looked at ww3schools.com and they showed me how to do a drop down menu. basically you have your list in a
<option> thing 1 </option>
<option> thing 2 </option>
After typing out 3 of these, I decided "No way. There has to be a quicker way." I asked myself, what could generate all of these quickly. The answer came to me quickly-excel.
So i copied and pasted what was generated, deleted the empty spaces, and voila. Job done. It probably took me a third of the time that was needed to do it all by hand.
By the way, these are all IDs that i gave each and every photo. For example, the first photo in the 2011 lot is calleed 2011_1
So i added these IDs to the menu that pops up under each photo so that students can quickly know what the photo they want to comment on is.
And, here it is! My drop down menu.
So now, another problem has arisen. What do I do after the user has filled in the form and clicked submit...well currently, my code says "after the button is clicked, show an alert telling the person that they have commented, then return true-redirect them to the page with the close button"
Well, now i need "after the button is clicked, FIRST, insert everything into the mysql table (use PHP), THEN show an alert telling the person that they have commented, then return true-redirect them to the page with the close button"


This means that I need to somehow put PHP into Javascript. I seem to recall searching this up-everything pointed me to AJAX. But i searched it up again anyway
http://www.hotscripts.com/forums/javascript/39278-php-inside-javascript.html
This website confirmed that i need AJAX. Fine, I'll do some notes and some research on it tommorow

Monday, 23 January 2012

Almost there!

 Putting together the table. I'm in my room, so I dont have access to the internet...which explains why the images  arent showing up.

Miraculously, i shifted my laptop about 10cm to the right and suddenly WI-FI appears and I can see my images. Just one problem though....they're kind of emmm...how do i put it. Lengthening the website. I should disable the scroll bar...At least for the bottom

 Took me some time to realize that javascript didnt recognize the word, margin-left, only marginLeft...But...new problem now. I want it to be so that everytime I click the arrow button, the table shifts a bit. This means incrementing or decrementing a margin. I picked marginLeft.

http://api.jquery.com/css/
I searched up CSS and Javascript increment. And would you believe it? There it is. I just used += or -=. I had tried ++ or --which worked in my previous experiences of programming such as C++ where ++ can be used to increment
Okay, i fixed the scroll bars....so I do believe i'm done with this bit!
http://www.dreamincode.net/forums/topic/32236-hide-horizontal-scrollbars/

Idea

Okay, after a good long sleep, I've come up with the idea for the folder section. I'm going to be doing that today.
Okay, so basically I have folders. I have a table. First row is all the same. Folder after folder. Below that row, is another row. That row is for labelling the folders.

Through javscript, I will shift the table either to the left or right at every click of the arrow.

Sunday, 22 January 2012

I've made my decision

I've decided. I'm going to thoroughly educate myself in JQuery/ Javascript before I attempt the photo gallery. I learn best when I take notes...so here goes!

http://www.w3schools.com/jquery/
<script type="text/javascript" src="jquery.js"></script>Can be used to embed javascript files. Which is really handy when you have long confusing lines code. Oh and remember to put all the stuff in the header if it's in the actual file.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>This is the JQuery library. Always include it.

$(selector).action()
This is the syntax.
$ defines JQuery
Selector means things such as this, "p", "p.insertclassnamehere", "#elementswiththisid"
You can select pretty much anything. http://www.w3schools.com/jquery/jquery_selectors.asp
Actions is the thing you do with the selector such as hide(), show().
Hide() and Show() are actually...
hide/show(speed, callback)
Speed is how fast it happens. It can fade in/out and can "fast", "slow", "normal", ___miliseconds
Callback means what happens after all this is done.For example
$("p").hide(1000,function(){
  alert("The paragraph is now hidden");
});
After P is hidden, callback makes the alert spring up.
Toggle() is similar just loads better since it's hide and show combined together. It also has speed and callback
There's also slideUp, slideDown, slideToggle, fadeIn, fadeOut, all with speed and callback
fadeTo has speed, opacity (with 0-1 i think) and callback in that order

There's also html() which changes text to other text
$("p").html("W3Schools");
this changes stuff with p tags to the words "w3schools"
prepend() and append() are similar. Append adds it to the end and prepend adds it to the front
$(document).ready(function(){Insertstuffyouwanttodo});
This ensures that the document is fully loaded before anything runs/ executes. It means "when the DOCUMENT is READY do the FUNCTION of....whatever"
Therefore this kind of thing works too...
$("button").click(function(){})
"when the thing with the BUTTON tag is CLICKED do the FUNCTION of...whatever"
this "whatever" could be
$("p").hide();which means "If it has P tags, hide it."

I think the CLICK is called an event handler. Other event handlers are...
ready, click, dblclick, mouseover

$(selector).animate({params},[speed],[easing],[callback])
Phew. this is crazy. It's custom animation. Okay, we've gone through selector already, animate is an action, gone through callbacks and speed
So params is CSS properties. Just list them out like this
{width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"}
 
CSS
css("name") returns the property value of the "name"
css("name","value") sets the css value to "value" for the "name"
css({"property":"value"} assigns css properties (for example
    $("p").css({"background-color":"yellow","font-size":"200%"});
height/width ("__px");
changes the size
 

Fixed form validation

Yesterday, I fixed the form validation for the comments of the photogallery.

Haha,, it turned out that I had to state every single one of the possiblities and I couldnt just go X || Y== Null


If all the fields are not filled in, an alert will appear, if they are, an alert will appear to tell you it has commented and a button to close the window will appear
I checked with my client last night about designs and he said yes to my idea. So first, let's make some icons. I decided that I would folders, and since I didnt know how to draw one, I traced off a print screen of one of my folders with the pen tool
So I coloured, shaded and decided to make an arrow since I had the feeling I would need it
Oh, one more thing, in my time plan (that is, the more updated one)- I made a miscalculation. I now have 7 days to create this photo gallery. I forgot to factor in this weekend, I thought i only had 1 week not 1 week+1 weekend.


And yes, I sent an email to my dad and after he looked at it, he called me into the room to say he was satisfied, yet when I asked him to try out the editing on CushyCMS, he seemed surprised and happy. Well, I'm glad my work is appreciated.

Update on Project Notebook

Okay, earlier on in my journal entries, I had photos of my notebook-which i use to jot down ideas and brainstorm. A month ago, we got a scanner, so I might as well scan all the pages here just to make it clearer
Sorting out ideas at first.


Planning designs for photo galleries

 More designs for photo galleries
Layout designs for website


Brainstorming password system with client, making sure it's what he wants

Attempt to sort out search engine-failed

Saturday, 21 January 2012

???

So in the end, even the google thing didnt work. After doing some research I found that google had to index your site first and it took ages to do so. So i submitted my website to google, tried the search engine again...nothing. No results. At all. This is ridiculous. So, completely unable to manage it, I emailed my aunt who had suggested this in the first place.
So, day 1 was a failure...I'll leave the search engine problem to my aunt and see if she has any clue as to what is happening.
Meanwhile, this morning, when I googled hisfield.netau.net to check if google had indexed the website something funny came up
Hi webhosting? What kind of title is that? I must add a title tag. Maybe this will fix things up.

Friday, 20 January 2012

Impossible

I have now determined that a search engine is just impossible to make from scartch. The best i could do was an extremely slow search engine and I could find no ways to speed it up. I only managed to fix 1 out of the 4 problems because I did not understand enough of PHP and no matter how much research I did, I still did not understand. Therefore, now I will fall back on my back up plan.


That is, to use the http://tools.digitalpoint.com/site_search.php that my Aunt Heidi told me about some time ago. This will allow me to save time and work harder on the photo gallery- the more important aspect of the website

Update on Search Engines

It's going along brilliantly with the aid of the website I mentioned in my previous post. Though I had a few problems (currently i am still solving a few)

1) When I created tables for MySQL- I had almost forgotten, luckily I had previous blog posts to refer to-Anyway, the main problem was that in the tutorial it had told me to type "Type=MyISAM", but it didnt work. I thought I had made a mistake so I tried again. Nothing. So i did some research here http://www.devraju.com/joomla/joomla-1-5-22-installation-sql-problem-typemyisam-solution-enginemyisam/
and found that the word wasnt "type" it was "engine". I tried it and it worked. Thank god. It only took me 15 minutes.
So I created my tables and checked them with the Show Tables thing.


Then, I copied and pasted the PHP codes on the tutorial and edited it slightly since my username was not "root" but "admin" and I had no password. Also I simplified the first bit of the code with the help of this website
http://phpeasystep.com/phptu/27.html
It simplified the URL retrieving bit at the beginning. Right now, the theory is quite clear to me but I still cant quite put it into words. So, if i ever need a reminder, I must look at
http://www.devarticles.com/c/a/HTML/Building-A-Search-Engine/
again

I did all this on my localhost/ testing instead of on my normal files because it's kept simpler this way. However, I've got a few little problems i must fix

Thursday, 19 January 2012

Note to Self

http://www.devarticles.com/c/a/HTML/Building-A-Search-Engine/
Note to self- this is a really good site for search engines

Through this, i found that it was possible for PHP to grab content and put it in a MySQL table. This simplifies things.
Ehh, when i opened up my project again I saw a layout problem. So I put borders around the table to allow myself to see the problem was


Turns out it was just a few br tags. So i fixed that, and it looks round about right now.

Tuesday, 17 January 2012

Return

Apologies for not working for 5 weeks. I had christmas vacation (which i spent revising) and mock exams. Finally, my mock exams are over. They ended yesterday. Now, I need to face the reality of my time schedule which was destroyed by 5 week lapse.

I plan to work hard next week, which I have off due to Chinese New Year, in order to catch up. If i work hard enough, it will be possible to make up for 5 weeks worth of work.

Also, good news, Sony's warranty allowed them to fix my laptop so I have all my work back. On the last day of term, i finally had a brain wave about how to kill two birds with one stone by creating the search engine. I wrote it down on paper and I will scan it and post it here soon.


Now...Plan of Action for CNY
Day 1
1) Create search engine-1 day

Day 2
2) Upload to site and try Cushy CMS-3 hours
3) Handover to client- remember to mention missing things-day 2
4) design photo gallery-3 designs- 3 hours
5) send to client to pick-5 minutes

Day 3
6) research how client can upload-4-6 hours if necessary
7) upload to image hosts-1 hour

Day 4,5,6,7
8) create image gallery- 4 days

CNY ends
9) Upload everything-1 day
10) send to client

Oh. Yes, i forgot. The plan of action for now (wednesday) to end of school (friday).
1) More research on search engines
2) clarify ideas and theories