![]() |
![]() |
![]() |
You Are Here: Home : cape.computing : Developers' Info |
|||
|
|
Getting started with MySQL
There will be a very simple sample table set up in your database for initial testing. You can add any number of production tables in this database and, at any time, delete the sample. The sample table contains a list of people from Bedrock. The tablename is 'bedrock'. The fields in this table are:
Three SQL client programs are available:
Example connection to MySQL using PHP:
function getDBConnection() {
static $cnx;
if (is_resource($cnx)) {
return $cnx;
} else {
$servername = yourmysqlservername;
$username = yourmysqlusername;
$password = yourmysqlpassword;
$dbName = yourmysqldatabase;
/* make connection to database */
$cnx = MYSQL_CONNECT($servername, $username, $password) OR DIE ("Unable to connect to database");
@mysql_select_db($dbName, $cnx) or die ("Unable to select database");
return $cnx;
}
}
$cnx = getDBConnection();
$query = "SELECT * FROM bedrock";
$result = MYSQL_QUERY($query,$cnx);
IF ($result) {
WHILE ($row = mysql_fetch_assoc ($result)) :
print "$row[userid] $row[firstname] $row[lastname]";
ENDWHILE;
}
For more help using MySQL in PHP, see http://us3.php.net/manual/en/ref.mysql.php . Example connection to MySQL using Perl:
use DBI;
my $dbh = DBI->connect("DBI:mysql:yourmysqldatabase:yourmysqlservername",yourmysqlusername,yourmysqlpassword) or die("can't connect to db");
my $st = qq{SELECT * FROM bedrock};
my $sth = $dbh->prepare($st);
$sth->execute or warn $dbh->errstr ;
while(@record = $sth->fetchrow_array) {
print "$record[0] $record[1] $record[2]";
}
For more help using MySQL in Perl, see http://www.perl.com/pub/a/1999/10/DBI.html .
Related PagesSecuring your data is an essential component of Electronic Commerce.
Cape.Com is a strong proponent of Open System, Standards based, non-proprietary solutions.
A description of the various levels of services available for E-commerce sites.
Available CPAN modules and related information
Various software development tools that are available to webmasters.
Having SSH/Telnet access to your site is a must if you'll be developing customized CGI scripts.
Related LinksInformation and Documentation on Cape.Com's favorite Data Server, MySQL.
The Source for the latest and best information about our most
indispensable information system programming language, Perl.
This is the MySQL reference manual.
This version documents the 3.21.33 version of MySQL.
MySQL is a basically free, very fast SQL database server.
Open Source Resources for Advanced Webmasters - PHP, Apache, Perl, MySQL and more.
Detailed information about CPAN modules.
A vital reference for using DBI.pm with MySQL.
We're not sure how they choose the animals that emblazon the covers
of their excellent reference books, but thanks to ORA, the camel and
Perl are forever linked.
Some PHP Wonks share valuable insight and information into using PHP.
The authorized source of information and documentation on Cape.Com's
Server-Side Scripting Language, PHP. Similar to ASP or Cold Fusion,
PHP is language that can be embedded within your HTML to connect to
an SQL database, process forms, create dynamic effects, manage
cookies, etc.
The information presented in this section is deemed accurate but is
not guaranteed. It is provided as a free service to our subscribers
and clients. Additionally, Cape.Com, Inc. exercises no editorial control
over any links that are outside the www.cape.com domain and the content
of these sites does not necessarily represent the views and opinions
of our Company, its employees or clients.
|
|
|
||