All posts by Ruturaj Vartak

Apache beginings

For guys who have reached here, but still don’t know what httpd is,
Apache is a web server, For all the web pages, websites, blogs, image galleries that are hosted on the web, there needs to be server who “serves” these documents (pages, images, files) to the client (the user’s browser)

Apache got its name from … well… its nothing but a “A patchy server”, httpd apache is an open-source project, which was programmed by many programmers over the world. And everytime a bug-fix, a new feature was required, the main code was just “patched”. And hence it got its name Apache.

Apache being a standard web-browser, runs on port 80, this is the standard HTTP port. Before you begin ahead, let me warn you changing the settings of Apache can change the way a website behaves, and to edit its settings you need root access or Administrator access.

To control apache, you basically need to edit 2 important files “httpd.conf” and “.htaccess”

Code for writing the comment to the DB

Now create a new page called ‘addcomment.php’

<?php
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('yourdb');

$comdate = $_POST['comdate'];
$articleid = $_POST['articleid'];
$comsubject = htmlspecialchars(addslashes($_POST['comsubject']));
$comuser = htmlspecialchars(addslashes($_POST['comuser']));
$comtext = htmlspecialchars(addslashes($_POST['comtext']));

//write the query
$sql = "insert into comments(comdate, articleid, comsubject, comuser, comtext)";
$sql .= " values ('" . $comdate . "', " . $articleid . ", '" . $comsubject . "', '" . $comuser . "', '" . $comtext . "');";

if (!@mysql_query($sql)) {
  echo ('We are unable to register your comment, sorry');
} else {
  echo ("Your comment was added successfully<br>");
  echo ("<A HREF="article.php">Back to Articles</A>");
}

mysql_close($conn);
?> 

User Interface for adding comments

Now that we have had some article in our dB, it is now time to show the article to the world. Plus we need to show the comment to them

Let us make a page called as ‘article.php’ and the article is fetched by getting the a url as ‘article.php?articleid=1’ This will fetch the article # 1 and is stored in the DB as articleid=1

If the articleid query is not given then the page has to display all the aritcle listing with the article subject as an link to ‘article.php?article=[the articleid]’

<?php
//if articleid query is not set, show all the article listing
if (!isset($_GET['articleid'])) {

$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('yourdb');

$sql = "select * from articles;";
$result = mysql_query($sql);

echo('<table boder=0 cellpadding=3 cellspacing=1>');
while ($row = mysql_fetch_assoc($result)) {
  echo('<tr>);
  echo('<td>);
  echo('<a href="aricle.php?articleid='.$row['articleid'].'"><b>'.$row['articlesubject'].'</b></a>');
  echo('<tr>);
  echo('<td>);
  echo($row['articlesubject']);
}
echo('</table>')
mysql_close($conn);

} else {

$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('yourdb');

$sql = "select * from articles where articleid=" . $_GET['articleid'] . ";";

if (!($result = @mysql_query($sql))) {
  echo('Sorry We are not able to process your request');
} else {
  //now display the data
  $row = mysql_fetch_assoc($result);
  echo ("<p><b>" . nl2br(htmlspecialchars($row['articlesubject'])) .
"</b>");
  echo ("<p>".nl2br(htmlspecialchars($row['articletext']))."<p>");
?>

  Add Comment
  <table>
  <form name='comment' action'addcomment.php' method=post >
  <input type=hidden name='comdate' value="<?php echo(date("Y-m-d H:i:s"))?>">
  <input type=hidden name='articleid' value="<?php echo($_GET['articleid'])?>">
  <tr><td>
  Subject<input type=text name='comsubject' />
  <tr><td>
  User<input type=text name='comuser' />
  <tr><td>
  <textarea name='comtext' rows=15 cols=50></textarea>
  <input type=submit value='Post Comment' />
  </form>
  </table>

<?php
  //now show all the comments for this article
  
  $sql = "select * from comments where articleid=" . $_GET['articleid'] . ";";   $result = mysql_query($sql);
  if (mysql_num_rows($result)<1) {
    echo('No comments posted for this article');
} else {
    while ($row = mysql_fetch_assoc($result)) {
      echo('<p>');
      echo( htmlspechialchars(stripslashes($row['comsubject'])) . ' by ' . htmlspechialchars(stripslashes($row['comuser'])) . ' on ' date("d M Y h:i a", strtotime($row['comdate'])) . '<br>');
      echo( nl2br(htmlspechialchars(stripslashes($row['comtext']))) );
    }
  }
  mysql_close($conn);
  }

}
?>

This now completes the code for viewing the article, the page also displays a form which as a subject textbox, a username textbox and a textarea for comment text.
When user clicks the ‘Post Comment’ button, the data is ‘post’ fed to the page ‘addcomment.php’

Basics

This entry is part 2 of 41 in the series Guitar

An acoustic guitar has 6 strings, hence the “6 string” 🙂
It starts from the E string (this is the string with the lowest pitch, or lowest frequency note), then the A string, followed by the D, G, B strings. And the last one is the e string. This one is the string with the highest pitch. This e sting produces the “E” note of the next octave begining from the base E string.

We’ll denote it as.., This is the plan view (top view) of the guitar, facing the strings.

e +---------------+
B +---------------+
G +---------------+
D +---------------+
A +---------------+
E +---------------+

Now hold the guitar as you generally hold it, the body of it on the lap, and your base of your right hand (considering your are right-handed) on the bridge. Bridge is the point from where the guitar strings start, it is NOT the end where you tune the string with the knobs.

Hold your thumb and index finger as you hold a pen, withing that grip hold the plectrum (pick). The blade of the pick should be at an angle to the strings, and not directly flat to the strings.

Now practice picking the strings, begining from the base E string to the high e string. All the picking should be down strokes. Go in an easy manner, till you get a feel of distances between the strings, etc…

Once you are comfortable with the simple picking start picking alternate strings. i.e. pick E, D, then A, G, then D, B, and G, e. and then back up again. This will help you in getting a hold of picking alternate, different strings.

I’ll explain you a notation that you will follow all over, It is not my notation, probably you must have seen it somewhere.
When I say you play C note, I’ll specify a fret. A fret is marking on which you play a note, to play a note you press your finger just before the nth fret (the fret that is mentioned to produce the note).
So…

e +---------------+
B +---------------+
G +---------------+
D +----0----------+
A +--3------------+
E +---------------+

..means play the 3rd fret on the A string to produce the C note, then the play open D string (i.e do not fret the string anywhere) to play the D note.

Guitar Tutorial

This entry is part 1 of 41 in the series Guitar

This is my guitar class diary, you may consider it to be as your tutorial, guide or whatever, my purpose to publish this one is to keep the contents of my guitar class on the web.
thats it.

I start from my first class where I knew only 1 thing about guitar and that is “6 string” guitar or something… 🙂 quite an information to begin with.

Lets start now…