Example for updating a record in a database with perl and the DBU module.
Example for updating a record in a database with perl and the DBU module.
Tags: sql update , perl database , dbu module
Code Snippet:
#!/usr/bin/perl
# Use the DBI module
USE DBI;
# PERL SQL Update Example
MY $dsn = 'DBI:mysql:dictionary:space.powweb.com';
MY $db_user_name = 'ssadmin';
MY $db_password = 'dictionary';
MY $password = "dictionary";
# Connect to the database
# Note this connection can be used to
# execute more than one statement
# on any number of tables in the database
MY $dbh = DBI->connect($dsn, $db_user_name, $db_password) || DIE "Connect failed: $DBI::errstr\n";
# Create the statement.
$stmt = "UPDATE Player_Stats SET total_games_played = '199' WHERE username LIKE '%joe'";
# Prepare and execute the SQL query
$sth = $dbh->prepare($stmt) || DIE "prepare: $stmt: $DBI::errstr";
# Execute the statement
$sth->execute();
$sth->finish();
$dbh->disconnect();
PRINT "Content-type: text/html\n\n";
PRINT "Done!";
EXIT;
ActionScript - ActionScript 3 - Apache - AppleScript - ASP - Assembler - Bash - C - C# - C++ - ColdFusion - CSS - Delphi - DOS Batch - Fortran - HTML - iPhone - Java - JavaScript - jQuery - Lisp - MatLab - Maxscript - MXML - MySQL - Objective C - Other - Pascal - Perl - PHP - PL SQL - Prolog - Pseudocode - Python - Rails - SmallTalk - Smarty - SML - SPSS - SQL - SVN - Symfony - TCL - VB.NET - Visual Basic - XHTML - XML - XSLT
© 2000-2015 Xentrik.Net