Programming

Snippets of code {asp, css, htm, js, php, sql, xml} that perform a variety of common actions.

asp
Database Connectivity
FileSystemObject
Regular Expressions

css
Attributes
Classes
Elements
Pseudo-classes
Selectors

htm
Attributes
Elements

js
AJax
DOM
Events

php
Database Connectivity
EMail automation
File Transfer Protocol
File System
Regular Expressions

sql
Create DB and Tables
Add and Alter Columns and Datatypes

xml
Constructor Objects
Parsing Objects
Translation and Transport mechanisms

 




 
pHp – Create a new database
* Remember to replace “???” with your password.

<?php

function db_new($dbName, $dsConn)
{
 if ($dsConn)
 {
  mysql_query(“CREATE DATABASE ” . $dbName, $dsConn);
  echo “Database ” . $dbName . ” created successfully.”;
  mysql_close($dSConn);
 }
 else
 {
  echo “Connection FAILED with MySql. :” . mysql_error();
 }
}

$nConn = mysql_connect(“localhost”, “root”, “???“);
db_new(“example_db_01”, $nConn);

?>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: