Rami Addady | 1 Oct 2005 15:53
Picon

Fail to migrate non Unicode data to mysql 4.1.10

Hello,

I'm migrating application and database form Mysql 3.23 to
mysql 4.1.10 and perl v5.8.5 on the latest version of CentOS 4.1 (RedHat 
AS 4.1 clone)

The tables was create using Hebrew character set:
CREATE DATABASE `table-name` DEFAULT CHARACTER SET hebrew COLLATE
hebrew_general_ci;

And all the data was inserted from the old database dump.

Only from Perl I can't work properly with this Hebrew data. Perl application
can't display the Hebrew text or insert proper Hebrew.  DBI module
fetch ????? values  and insert  nulls instead of Hebrew character to/from
the DB.

Other application like php (using phpmyadmin) or mysql shell command
work fine with Hebrew on the same table.

Installing the latest stable DBD module (DBD-mysql-3.0002) didn't help much.

Please advice.

Regards,
Rami Addady

--

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
(Continue reading)

Shlomi Zlatopolsky | 1 Oct 2005 19:22
Picon

RE: Fail to migrate non Unicode data to mysql 4.1.10

Try to use the following string after each establishing connection:

	$dbh->do("SET character_set_client = hebrew");
	$dbh->do("SET character_set_connection = hebrew"); 
	$dbh->do("SET character_set_results = hebrew");

or (if you will use UTF-8):

	$dbh->do("SET character_set_client = utf8");
	$dbh->do("SET character_set_connection = utf8"); 
	$dbh->do("SET character_set_results = utf8");

You can also add client section, default charset in my.ini file:

	[mysql]
	default-character-set=hebrew

or:

	[mysql]
	default-character-set=utf8

-----Original Message-----
From: Rami Addady [mailto:rami <at> active.co.il] 
Sent: Saturday, October 01, 2005 3:53 PM
To: perl <at> lists.mysql.com
Subject: Fail to migrate non Unicode data to mysql 4.1.10

Hello,

(Continue reading)

Vittorio Bertola | 3 Oct 2005 14:58

Mysql errors after upgrading DBI and DBD::mysql

Hello,

we have had a strange problem with DBI and DBD::mysql, so I thought to 
post it here to see if other people had similar issues or advice.

Last week, we moved some services from one server to another one. These 
services are run by perl daemons which keep connections open permanently 
to mysql and perform queries and actions when necessary. We use Gentoo 
Linux, and we expected the servers to be substantially equivalent, 
except that the new one had less CPU power. The old server had kernel 
2.6.10, DBI (package dev-perl/DBI) 1.38 and DBD::mysql (package 
dev-perl/DBD-mysql) 2.1027. The new one had kernel 2.6.8. Mysql is 
4.0.20 on both machines, compiled manually in /opt. When migrating, to 
ensure data consistency, we did a copy of /var/lib/mysql/* from the old 
to the new server.

When we started the services, immediately we started to get this kind of 
errors in the error log for mysql:

Aborted connection 15246 to db: '[...]' user: '[...]' host: `localhost' 
(Got an error reading communication packets)

They were happening very often, e.g. an error of this kind every few 
seconds. As a results, services were broken: queries would very often 
fail at the ->fetchrow() even after a successful ->execute().

In the end, we realized that the new server had updated versions of DBI
(1.46) and DBD-mysql (2.9003). We downgraded the first package to the 
old version, and errors seemed to slow down a bit. We downgraded the 
second one, and they almost disappeared. Now we get a couple of errors 
(Continue reading)

Douglas S. Davis | 4 Oct 2005 17:37
Favicon

Programming Question

Hi,

I'm writing a Perl program to create a web page that allows faculty 
at the college where I work to propose new courses using a web 
form.  At one point during the filling out of the form, the faculty 
member must propose a course number to be used (like "101" for 
English 101).  I have a link that the faculty member can click that 
runs a javascript routine that looks at the department choice made 
earlier in the form and then opens a new window to display the 
available course numbers--those not already in use by other courses 
in their specified department.

The javascript just runs a Perl program to create the window and the 
Perl program queries a MySQL table to get all of the currently in use 
numbers in the specified department.  I then need to compare the 
results of the query with the list of all possible numbers (100 - 
499) to determine which of the possible numbers are *not* in use, and 
then display the available numbers in the new window for the faculty 
member to choose from.

My problem (and I am sure it must be simple to do) is that I can't 
figure out how to compare the list of possible numbers (100 - 499) 
with the list of already in use numbers returned by my query.  I've 
tried various loops and while statements all to no avail.  Usually 
what I get is that for *each* number in the result set of my query, 
it prints out all of the numbers from 100 - 499.

Can anyone point me in the right direction.    So in other words, 
when I do my fetchrow() on the MySQL table, how can I take the 
results and compare them to the 100 - 499 set of numbers.
(Continue reading)

Rhesa Rozendaal | 4 Oct 2005 17:47

Re: Programming Question

Douglas S. Davis wrote:
> Hi,
> 
> My problem (and I am sure it must be simple to do) is that I can't 
> figure out how to compare the list of possible numbers (100 - 499) 
> with the list of already in use numbers returned by my query.  I've 
> tried various loops and while statements all to no avail.  Usually 
> what I get is that for *each* number in the result set of my query, 
> it prints out all of the numbers from 100 - 499.

Sounds like you could use a sieve, just like the famous Sieve of Eratosthenes.

> Can anyone point me in the right direction.    So in other words, 
> when I do my fetchrow() on the MySQL table, how can I take the 
> results and compare them to the 100 - 499 set of numbers.

It roughly goes like this:

# create a hash containing all numbers
      <at> sieve{100 .. 499} = (1)x399;

# loop over your "in use" numbers, and delete them from the hash
     while( my ($n) = $sth->fetchrow ) {
         delete $sieve{$n};
     }

# what you have left is the available numbers
      <at> available = sort keys %sieve;

HTH,
(Continue reading)

Christopher Pryce | 4 Oct 2005 17:59

Re: Programming Question

[ CC to Author ]

On Oct 4, 2005, at 10:37 AM, Douglas S. Davis wrote:

> My problem (and I am sure it must be simple to do) is that I can't  
> figure out how to compare the list of possible numbers (100 - 499)  
> with the list of already in use numbers returned by my query.  I've  
> tried various loops and while statements all to no avail.  Usually  
> what I get is that for *each* number in the result set of my query, it  
> prints out all of the numbers from 100 - 499.
>
> Can anyone point me in the right direction.    So in other words, when  
> I do my fetchrow() on the MySQL table, how can I take the results and  
> compare them to the 100 - 499 set of numbers.
>

My suggestion - don't fetch each row, unless there is a compelling  
reason. Fetch all of the matching rows at once as a hashref. For  
instance, if you have a table called tblcourses with the following  
structure:

courseNumber | courseTitle | departmentNumber | creditHours |  
instructor |
------------------------------------------------------------------------ 
--

# UNTESTED
my $keyfield = 'courseNumber';

my $courses = $dbh->selectall_hashref( q(Select * From tblcourses Where  
(Continue reading)

Douglas S. Davis | 4 Oct 2005 18:04
Favicon

Solved - THANK YOU!

Thank you, thank you, thank you, to all who responded to my question 
about comparing the two arrays.  A couple people suggested a method 
from The Perl Cookbook (I'll have to get a copy) that ended up 
working just fine.

Thank you all so much for taking the time to help.  I was very 
frustrated.  I knew it was simple, but just couldn't wrap my head around it.

                                                         Douglas

Douglas S. Davis
Programmer/Analyst
Haverford College
Administrative Computing
370 Lancaster Ave.
Haverford, PA 19041
610-896-4206 

--

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules <at> m.gmane.org

J Wermont | 16 Oct 2005 02:14
Favicon

Giving Javascript code access to Perl variables

In a .CGI file, I'd like to include some Javascript code (which will be
written to the output file sent to the client's browser), which will
access Perl variables that were set in the same CGI file.

It seems to work in some cases. For example, I have a CGI file that
includes this code:

   #!/usr/local/bin/perl

   ... Perl code ...

   $loopcount = 4;

   ... more Perl code ...

   print << "ENDOFPAGE";

   ... HTML code ...

   <script language="Javascript" type="text/javascript">

   for (i=0; i<$loopcount; i++) {
      document.write ("Hello world<br>")
   }

   </script>

   ... more HTML ...

   ENDOFPAGE
(Continue reading)

Tony Dean | 16 Oct 2005 18:20

Re: Giving Javascript code access to Perl variables

The simplest approach, as I see it, is just to interrupt the print of the JS
code at the point you wish to make the declaration.

my ( <at> array) = ('now','is','the','time','for','all','good','men');
my ( <at> new, $tmp, $val);

for $val ( <at> array) { push  <at> new, "'$val'";} # Ensure quotes are present
$tmp = join ',',  <at> new;

# Print bulk JS code

print "var array_name = new Array($tmp);"; # Now in JS style

# Print more JS code

Hope this helps... Tony Dean

----- Original Message ----- 
From: "J Wermont" <jwermont <at> sonic.net>
To: <perl <at> lists.mysql.com>
Sent: Sunday, October 16, 2005 1:14 AM
Subject: Giving Javascript code access to Perl variables

> In a .CGI file, I'd like to include some Javascript code (which will be
> written to the output file sent to the client's browser), which will
> access Perl variables that were set in the same CGI file.
>
> It seems to work in some cases. For example, I have a CGI file that
> includes this code:
>
(Continue reading)

Felipe Gasper | 16 Oct 2005 19:11
Picon
Favicon

Re: Giving Javascript code access to Perl variables

I'd say the best way to do this is the JSON module on CPAN.

-FG

Quoth J Wermont on 10/15/2005 8:14 PM...
> In a .CGI file, I'd like to include some Javascript code (which will be
> written to the output file sent to the client's browser), which will
> access Perl variables that were set in the same CGI file.
> 
> It seems to work in some cases. For example, I have a CGI file that
> includes this code:
> 
>    #!/usr/local/bin/perl
>    
>    ... Perl code ...
> 
>    $loopcount = 4;
>    
>    ... more Perl code ...
>    
>    print << "ENDOFPAGE";
>    
>    ... HTML code ...
>    
>    <script language="Javascript" type="text/javascript">
>    
>    for (i=0; i<$loopcount; i++) {
>       document.write ("Hello world<br>")
>    }
>    
(Continue reading)


Gmane