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