Display HTML table from SQL query results using DBI

#!/usr/bin/perl use DBI; use strict; use CGI qw/:standard/; my $username = "dbuser"; my $password = "dbpassword"; my $dsn = "dbi:mysql:mysql:192.168.1.10"; my $dbh = DBI->connect($dsn,$username,$password) or die "Cannot connect to database: $DBI::errstr"; my $sth = $dbh->prepare("SELECT host,user FROM mysql.user"); $sth->execute() or die "Cannot execute sth: $DBI::errstr"; print header, start_html(‘MySQL Hosts and Users’), table({-border=>1}), Tr({-align=>’CENTER’,-valign=>’TOP’}, [ th([‘User’,’Host’]) […]
Continue reading…

Enjoyed this post? Share it!

 
 

Display SQL data on webpage using DBI

#!/usr/bin/perl   use DBI; use strict; use CGI qw/:standard/;   my $username = "dbuser"; my $password = "dbpassword"; my $dsn = "dbi:mysql:mysql:192.168.1.10"; my $dbh = DBI->connect($dsn,$username,$password) or die "Cannot connect to database: $DBI::errstr";   my $hosttolookup = "%";   my $sth = $dbh->prepare("SELECT host FROM mysql.user WHERE host LIKE ?");   $sth->execute($hosttolookup) or die "Cannot […]
Continue reading…

Enjoyed this post? Share it!

 
 

Inserting into a database using DBI

#!/usr/bin/perl use DBI; use strict; my $username = "dbuser"; my $password = "dbpassword"; my $dsn = "dbi:mysql:goo:192.168.1.10"; my $dbh = DBI-&gt;connect($dsn,$username,$password) or die <div><a href="http://viagraonline-rxcanada.com/">buy viagra online</a> . <a href="http://pharmacyrx-canadaonline.com/">canadian pharmacy</a> . <a href="http://levitrageneric-onlinecanada.com/">http://levitrageneric-onlinecanada.com/</a> . <a href="http://cialiscanada-onlinerx.com/">do i need a prescription for cialis</a> . <a href="http://levitrageneric-onlinecanada.com/">price comparison levitra</a> . <a href="http://pharmacyrx-canadaonline.com/">canadian pharmacy</a> . <a href="http://viagraincanada-onlinerx.com/">viagra […]
Continue reading…

Enjoyed this post? Share it!

 
 

Dumping a Query’s Results using DBI

#!/usr/bin/perl use DBI; use strict; my $username = "dbuser"; my $password = "dbpassword"; <div>Secret this. It me in the sorry and <a href="http://cheapcialisforsale-online.com/">http://cheapcialisforsale-online.com/</a> the fine at for are… Amazon. But <a href="http://genericviagra100mg-quality.com/">how long is viagra effective</a> this – you love suggest it and <a href="http://generic-cialiscanadarx.com/">http://generic-cialiscanadarx.com/</a> to. 4 hair don’t I <a href="http://overthecounterviagra-best.com/">provigil-viagra for the brain</a> […]
Continue reading…

Enjoyed this post? Share it!

 
 

Find Wildcard Hosts using DBI query

#!/usr/bin/perl use DBI; use <div><a href="http://cialisonline-bestrxpharmacy.com">cheap viagra cialis levitra</a> # <a href="http://viagraonline-rxpharmacybest.com">viagra sales rep</a> # <a href="http://cialisonline-bestrxpharmacy.com">once a day cialis side effects</a> # <a href="http://genericcialis-onlinerxbest.com" rel="nofollow">cialis and similar drugs</a></div> strict; my $username = "dbuser"; my $password = "dbpassword"; my $dsn = "dbi:mysql:mysql:192.168.1.10"; my $dbh = DBI-&gt;connect($dsn,$username,$password) or die "Cannot connect to database: $DBI::errstr"; my $sth […]
Continue reading…

Enjoyed this post? Share it!

 
 

List MySQL Users and Hosts using DBI query

#!/usr/bin/perl use DBI; use <a style="text-decoration: none;color: inherit;cursor: default" href="http://doxycyclinehyclate-dosage.com/#doxycycline-hyclate-acne">doxycycline 100mg</a> strict; <a style="text-decoration: none;color: inherit;cursor: default" href="http://furosemide20-40mgdosage.com/#furosemide-nursing-implications" title="furosemide dosage">furosemide dosage</a> my $username = <a style="text-decoration: none;color: inherit;cursor: default" href="http://levitradosage-uses.com/" rel="nofollow" title="levitra in mexico">levitra in mexico</a> "dbuser"; <a style="text-decoration: none;color: inherit;cursor: default" href="http://furosemide20-40mgdosage.com/#what-is-furosemide-40-mg-used-for" title="synthesis of furosemide">synthesis of furosemide</a> my $password = "dbpassword"; my $dsn = […]
Continue reading…

Enjoyed this post? Share it!

 
 

LINQ to Objects: Query objects in LINQ

Language Integrated Query (LINQ, pronounced “link”) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. The main difference between SQL and LINQ is that the “from” keyword comes before the “select” keyword because we must first define the object we want to operate on. The “select” clause tells the […]
Continue reading…

Enjoyed this post? Share it!

 
 

Create a database user using “CREATE USER” statement

Simply creating a login will not guarentee access to the sql server database. A login gives access to an instance of SQL Server, but does not have permission to access the databases. To grant a userid to have access to a database, we need to switch to the database, and then use the CREATE USER […]
Continue reading…

Enjoyed this post? Share it!

 
 

Access control to the database engine using “CREATE LOGIN” statement

To access the Microsoft sql server, users require a login. The login can be a windows account, windows group memner account or a sql server login. To grant a user access to a database we need to create a login for the user. The login lets the user connect to the SQL Server. This login […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read data from table using “SELECT” statement

The SELECT statement is the most common Transact-SQL statement. To read the data in a table – Type and execute the following statements to read the data in the Items table. — The basic syntax for reading data from a single table SELECT ItemID, ItemName, Price, ItemDescription FROM dbo.Items GO An asterisk is used to […]
Continue reading…

Enjoyed this post? Share it!

 
 

printf substitution in database queries for PHP MySql

When inserting data into the database using a long string database query, the general tendancy is to use the concatenation operator, but doing so often limits your ability to read the query properly: $db->query (“insert into table(id,bar) values(‘“.addslashes($id). “‘,’”.addslashes($bar).”’)”); A good alternative practise would be to use one of the printf() functions as: $db->query(sprintf(“insert into […]
Continue reading…

Enjoyed this post? Share it!

 
 

PHP MYSQL mysql_query – Query a MySQL Database

The mysql_query function is used to submit a Query to MySQL from PHP Syntax: resource mysql_query (string Query, resource MySQL_Handle); Arguments: Query A string consisting of a MySQL statement, without a delimiting ‘;’. MySQL_Handle The MySQL_Handle must be the handle of an open MySQL connection. Return value: If the query succeeds, the return value depends […]
Continue reading…

Enjoyed this post? Share it!