Re: MySQL won't GRANT ALL ON cookbook.* ... ERROR 1044

2003-02-24 Thread fliptop
On Sun, 23 Feb 2003 at 20:09, Ed Sickafus opined:

ES:Server: Linux (RedHat 7.2) Apache 1.3.x
ES:I'm trying to run an introductory exercise out of MySQL Cookbook by Paul
ES:DeBois
ES:Accessing MySQL from a PC via PuTTY to ISP's UNIX
ES:I can get to the mysql prompt but no further.
[snip]

since your question has nothing to do with cgi, it would be better asked
on the dbi mailing list:

http://www.perl.com/pub/a/language/info/mailing-lists.html#db

or perhaps one of the mysql mailing lists:

http://www.mysql.com/documentation/lists.html


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: php like behavior for my perl CGI

2003-02-24 Thread Todd W
f'ups rearranged

  [EMAIL PROTECTED] wadet]$ perl
  sub box {
return('img src=p.gif height='.$_[0].' width='.$_[1].'');
  }
  print eot;
  table
tr
  td${\box(5,10)}/td
  td${\box(7,10)}/td
/tr
  /table
  eot
  Ctrl-D
  table
tr
  tdimg src=p.gif height=5 width=10/td
  tdimg src=p.gif height=7 width=10/td
/tr
  /table
 
  see:
 
  [EMAIL PROTECTED] wadet]$ perldoc perlref

Peter Kappus [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
...
 Aha!  This is exactly the kind of solution I was looking for.  I guess
what
 I'm doing here is passing a reference to a subroutine call?  \box(5,10)
and
 then turning it into a scalar?  ${}

Almost. In most contexts in perl, a { } construct is a BLOCK, and all code
in between the braces will be evaluated. So for our example, we call box
then return a reference to box()'s return value.

if a reference logically follows a $ in an interpolated string, the the
reference will be dereferenced.

Hence the desired results.

If (for some reason) we were passing a reference to the subroutine, it (
may ) look like this:

[EMAIL PROTECTED] wadet]$ perl
sub box {
  return('img src=p.gif height='.$_[0][0].' width='.$_[0][1].'');
}
print eot;
table
  tr
td${\box( [5,10] )}/td
td${\box( [7,10] )}/td
  /tr
/table
eot
Ctrl-D
table
  tr
tdimg src=p.gif height=5 width=10/td
tdimg src=p.gif height=7 width=10/td
  /tr
/table

and if you want to go OO:

package My::Img;

sub new {
  my($class, %params) = @_;
  return( bless( { %params }, $class ) );
}

sub box {
  my($self) = shift();
  return('img src=p.gif height='.$self-{height}.'
width='.$self-{width}.'');
}

package main;

print eot;
table
  tr
td${\ My::Img-new(height =5, width = 10)-box() }/td
td${\ My::Img-new(height =10, width = 5)-box() }/td
  /tr
/table
eot
Ctrl-D
table
  tr
tdimg src=p.gif height=5 width=10/td
tdimg src=p.gif height=10 width=5/td
  /tr
/table

but thats just silly ;0)

dont forget:

  see:
 
  [EMAIL PROTECTED] wadet]$ perldoc perlref

and for a real good time, check out

[EMAIL PROTECTED] wadet]$ perldoc perllol

 Quite ingenious.  While I'm sure I'll regret it later (and curse your good
 name as I'm wishing I'd taken the time to learn Mason or HTML::Template)
 this seems like a great quick fix for the time being.  And it never hurts
to
 learn a few new tricks!

Unfortunately theres nothing there I came up with on my own, and yes, new
tricks are always good for the 'ol grab bag =0).

HTH,

Todd W.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



NULL insertion

2003-02-24 Thread T. Murlidharan Nair
Hi!!
I need to insert NULL into the database using a perl CGI . So if a variable
is to be made NULL in perl and it needs to be used in an sql statement what
is best way to do it. Do I assign ' \N' to it or 'NULL' ?
Thanks and Cheers always!!
Murli




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: NULL insertion

2003-02-24 Thread Dennis Stout
 I need to insert NULL into the database using a perl CGI . So if a variable
 is to be made NULL in perl and it needs to be used in an sql statement what
 is best way to do it. Do I assign ' \N' to it or 'NULL' ?

Standard SQL syntax for presenting null is SET VARIABLE=NULL, but I'd need to
know what kind of database you were using before I could pound out some perl
code for you.

You cna probably do the code anyways, so I don't feel so bad :)  Anyways,
thats the SQL syntax.

Dennis Stout


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: NULL insertion

2003-02-24 Thread Scot Robnett
This assumes MySQL is your DB. I know there are other people on this list
that can offer more efficient solutions or pick this one apart...so feel
free. :)

***
#!/usr/bin/perl

use strict;
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use DBI;

my $q = new CGI;  # new CGI object

my %formdata = $q-Vars;  # NV pairs, use caution though because
  # items with multiple values will have
  # be called with references.


# Let's assume that %formdata looks like this:
# %formdata = (name  = Joe,
#phone = 888-555-1212,
#fax   = 888-555-1313);


# Connect to the database.
my $value = ; # Have to declare variables if we use strict.

my $dbh =
DBI-connect(DBI:mysql:database_name:localhost,username,password) or
die I could not connect to the database: $!;


# Prepare the SQL statement(s) for execution, then execute them.
foreach my $key(%formdata) {
 $value = $formdata{$key};
  my $sth = $dbh-prepare(qq|INSERT INTO
contactData(Firstname,PhoneNo,FaxNo)
 VALUES ($value,NULL,NULL)|) if($key eq name);
  my $sth = $dbh-prepare(qq|INSERT INTO
contactData(Firstname,PhoneNo,FaxNo)
 VALUES (NULL,$value,NULL)|) if($key eq phone);
  my $sth = $dbh-prepare(qq|INSERT INTO
contactData(Firstname,PhoneNo,FaxNo)
 VALUES (NULL,NULL,$value)|) if($key eq fax);
  $sth-execute;
}


# Commit the changes.
$dbh-commit;


# Disconnect from the database.
$dbh-disconnect;
1;


-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]







-Original Message-
From: T. Murlidharan Nair [mailto:[EMAIL PROTECTED]
Sent: Monday, February 24, 2003 4:55 PM
To: [EMAIL PROTECTED]
Subject: NULL insertion


Hi!!
I need to insert NULL into the database using a perl CGI . So if a variable
is to be made NULL in perl and it needs to be used in an sql statement what
is best way to do it. Do I assign ' \N' to it or 'NULL' ?
Thanks and Cheers always!!
Murli





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]