in reply to mySQL Query Problem
This code accepts the variable, inserts it into the table and retrieves the values correctly.#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect("DBI:mysql:test;host=localhost;" ."mysql_read_default_file=$ENV{HOME}/.my.cnf", undef,undef,{RaiseError => 1}); $dbh->do(qq{drop table if exists testq}); $dbh->do(qq{create table testq (i int not null, c varchar(50))}); my $sth= $dbh->prepare(qq{insert into testq values (?, ?)}); my $i = 10; my $msg = 'tengo todo por aprender ¿quien quiere enseñarme?'; $sth->execute($i, $msg); my @results = @{ $dbh->selectall_arrayref(qq{select * from testq})}; print "@$_\n" for @results; $dbh->disconnect();
my $dbh = DBI->connect("DBI:mysqlPP:test;host=localhost;", "gmax","mysecretpwd",{RaiseError => 1});
_ _ _ _ (_|| | |(_|>< _|
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: mySQL Query Problem
by kidd (Curate) on Feb 12, 2003 at 15:17 UTC |