Progged programming site

Programming source code, articles, tutorials, links and chat

create a MySQL database using PHP

This code snippet example shows how to  create a MySQL database using PHP

<?php

$result = mysql_create_db(”mydb”);
if ($result == false)
echo (”failure to create database”);

?>

Display all drives with Visual basic

This Visual basic example displays all drives on your system, you will need to place a combo box on the form.

Private Sub Form_Load()

Dim objfso As Scripting.FileSystemObject
Dim objDrives As drives, objDrive As drive
Set objfso = CreateObject(”Scripting.FileSystemObject”)
Set objDrives = objfso.drives

For Each objDrive In objobjDrives
Combo1.AddItem objDrive.DriveLetter
Next

End Sub

Create a directory using C#

This C# example shows how easy it is to create  a directory

using System;
using System.IO;

namespace csharp
{
class Class1
{
static void Main(string[] args)
{
DirectoryInfo dirInfo = null;
if (!Directory.Exists(@”d:\testdir”))

{
dirInfo = Directory.CreateDirectory(@”d:\testdir”);
Console.WriteLine(”Created directory”);
}

}

}

}

Log users IP address

This ASP example will retrieve a visitors IP address and store it in a file called log.txt. Note that the text file has to exist, you could of course create this or have some sort of validation that the file exists first.

<%
IPAddress=Request.ServerVariables (”REMOTE_ADDR”)
Set objFSO = CreateObject(”Scripting.FileSystemObject”)
Set objFile = objFSO.OpenTextFile(”c:\log.txt”, forappending)
objFile.WriteLine (IPAddress)
objFile.close
Set objFile=nothing
Set objFSO=nothing
%>

Sponsors