SMBI FAQ
- How can I access my database using PHP
- How can I access my database using PERL
- How can I send email using PHP / PERL
- Supports Java applets/Active-X and other browser object components
How can I access my database using PHP
You can create custom PHP scripts to access your database. Below are a few lines of PHP code you can use to access your database.
<?php
$link = mysql_connect("mysql", "admin", "testing1");
mysql_select_db("test");
$query = "SELECT * FROM employee";
$result = mysql_query($query);
while ($line = mysql_fetch_row($result))
{
foreach ($line as $value)
{
echo "$value | ";
}
}
mysql_close($link);
?>
How can I access my database using PERL
#!/usr/bin/perl -w
use DBI;
print "Content-type: text/html\n\n";
my $dsn = 'dbi:mysql:test:mysql:3306';
# set the user and password
my $user = 'admin';
my $pass = 'testing1';
# now connect and get a database handle
my $dbh = DBI->connect($dsn, $user, $pass)
or die "Can't connect to the DB: $DBI::errstr\n";
my $sth = $dbh->prepare("select emp_id, emp_name from employee");
$sth->execute;
while(@row = $sth->fetchrow_array()) {
print "$row[0]: $row[1]";
}
How can I send email using PHP / PERL
Before you can send email with Perl or PHP, you must complete the PHP/Perl Mail Setup process. To begin setting up PHP/Perl mail, click the "PHP/Perl Mail" link on the Create & Update or Index tabs of your Web Hosting Control Panel. The mail setup process allows you to customize the email address that users will see when you send them a message (for example, "From: siteowner@widgetdesigns.com").

PHP Code:
<?php
$message = "Before you can send email with Perl or PHP, you must complete the PHP/Perl Mail Setup process";
mail("remoshan@yahoo.com", "Request for a mail script using PHP",$message);
?>
PERL Code:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
$title='mail test';
$to='remoshan@yahoo.com';
$from= 'webmaster@smbprodremo99.com';
$subject='Using Sendmail (PERL)';
open(MAIL, "|/usr/sbin/sendmail -t");
## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message from Yahoo! \n";
close(MAIL);
Supports Java applets/Active-X and other browser object components
Sample code for java applets: Firstly, install the required "jar" file, here in the below example we have used "t.jar" file. Below example displays the stock ticker java applet component.
<applet
archive="t.jar"
code="f" width="500" height="19">
<param name="feed"
value="http://localhost/work/gigel/en/ticker-feed-yahoo.php">
<!--grid background color-->
<param name="gridColor" value="10,10,10">
<!--color for stock values when going down-->
<param name="downColor" value="255,100,100">
<!--color for stock values when going up-->
<param name="downColor" value="100,255,100">
<!--color to show symbols-->
<param name="symbolColor" value="180,180,180">
<!--color for stock value when same as old value-->
<param name="stayColor" value="150,150,150">
<!--text scrolling speed: try 5, 10, 15 etc-->
<param name="speed" value="22">
<!--time in milseconds between reading new stocks values from feed-->
<param name="refreshDelay" value="5000">
</applet>
