Re: using perl in mandrake

2001-06-07 Thread SAWMaster

I'm new to perl too, but I think I can help.  As far as I can tell,
perlscript is embeded right into an HTML file the same way you do VBScript
or JavaScript, so your file would have the regular *.html extention.  If on
the other hand, you are using a full fledged perl program, you can run it
from the command line, assuming you have an interpreter, which I'm sure
mandrake has?  I think the standard extention in this case is ".pl", but I
think you can also use ".cgi".  "perl myperlfile.pl" is the basic syntax
from the command line.  Or, you can put it in your web server's cgi-bin
directory, and then call the program from a   inside an HTML file.  Anyway, I might be
wrong on this because I'm not terribly familiar with PerScript, and I'm new
to Perl in general, but just in case I'm the only one who answers you (not
bloody likely)...at least you have something.  Lol. :)

-Dave

- Original Message -
From: bc <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 07, 2001 3:11 PM
Subject: using perl in mandrake


i have mandrake8 and use kde, i  normally use asp/vbScript and want to make
the move to perl. I just got  "learning perl" 2nd Ed. it does not seem to
tell me what to do w/ my script  i type, where to save it, what to save it
as (extention), and do i just ftp  it to my domain that is on a perl script
supported web server at mindspring,  and from there, just run that file that
i ftp'ed there with my browser? i  just need to get started and i shoud be
okee dokee learning the code on my own... thanks for directing me if you
can... :)




Re: INSERTing problems

2001-06-07 Thread SAWMaster

That makes complete sense in two ways, first the way you suggested it,
second, if I were to ever try to insert a record that was actually NULL for
instance if I didn't have a newCat to enter for one record...your suggestion
would handle that too...

Thanks for that.

But my main problem remains.  I can't seem to get any data into my database.
Unless I do it one field at a time...which would be preposterous.  There has
got to be a way to do this!

- Original Message -
From: Tillema, Glenn <[EMAIL PROTECTED]>
To: 'SAWMaster' <[EMAIL PROTECTED]>
Sent: Thursday, June 07, 2001 3:32 PM
Subject: RE: INSERTing problems


> I think your script is expecting a value for the eigth item ... try
passing
> it NULL.
>
>
> my example below assumes the field is called 'ID'.
>
> ie
>
> $newNULL = 'NULL';
> $sqlstatement = "INSERT INTO Full (freq, loc, desc, freqtype, cat, call,
tx, ID) VALUES (?,?,?,?,?,?,?,?)";
> $sth = $dbh->prepare($sqlstatement) || die $dbh->errstr;
> $sth->execute($newfreq, $newloc, $newdesc, $newfreqtype, $newcat,
$newcall,$newtx, $newNULL) || die $dbh->errstr;
>
> Glenn Tillema  [EMAIL PROTECTED]
> ADC Telecommunications, Inc.
> PO Box 1101, MS 508
> Minneapolis, MN  55440-1101
> Learn about ADC - The Broadband Company - www.adc.com
>



Searching and printing a text file

2001-06-19 Thread SAWMaster

Hi group!

Ok, I'm trying to open all files in the directory containing my script, and
search each one for lines containing my search string.  This is my code so
far:

$i = 0;
opendir(logdir, '.') or die "Can't open directory.";
print "Enter string to search for: ";
$searchstring = <>;
print "\n";
#print join("\n", readdir(logdir));
print "\n";
@filelist = readdir(logdir);
while($i < ($#filelist))
{
open(logfile, @filelist[$i]);
 $i++;
 while()
{
  #if(#line I'm currently on is m/$searchstring/i)
  {
   print;
  }
 }
}
print "Press enter to continue...";
<>;
$i = 0;
while($i < ($#filelist))
{
 close(logfile, @filelist[$i]);
 $i++;
}
closedir $logdir;

Now the problem is, how do I specify "The line I'm currently working on"?

Right now my program prints every line from every file in my directory, but
once I figure this out I think it should limit the output to only lines
containing my search string.


Can someone help me out?



Re: Searching and printing a text file

2001-06-19 Thread SAWMaster

$i = 0;
opendir(logdir, '.') or die "Can't open directory.";
print "Enter string to search for: ";
$search = <>;
print "\n";
#print join("\n", readdir(logdir));
print "\n";
@filelist = readdir(logdir);
while($i < ($#filelist))
{
 open(logfile, @filelist[$i]);
 $i++;
 while()
 {
  if(m/$search/i)
  {
   print;
  }
 }
}
print "\n";
print "Press enter to continue...";
<>;
$i = 0;
while($i < ($#filelist))
{
 close(logfile, @filelist[$i]);
 $i++;
}
closedir logdir;


Ok, I think I understand you, but things still are not working right.
 
> That's easy -- you don't.
> 
> When you said:
> 
> print;
> 
> you didn't specify what to print. So print printed $_,
> the default variable. Lots of functions either set or
> get the default variable if you don't tell them to do
> otherwise.
> 
> In the same vein:
> 
> while (<>) {
> 
> (with or without a handle name in the <>s)
> sets $_.
> 
> And:
> 
> if (/foo/) {
> 
> compares foo to $_.
> 
> Easy, huh?
> 
> Btw, the current line no is in $.
> 
> hth.
> 
> 



Re: Searching and printing a text file

2001-06-19 Thread SAWMaster

> Ok, I think I understand you, but things still are not working right.

Never mind, I forgot to chop my search string.  Works great now :)

TDH (That DID help) lol.



Newbie question about running programs from the command line.

2001-06-20 Thread SAWMaster

Hi group.

Short 'n sweet question.  Is there a way to run perl programs from the command line 
without having to precede usage with "perl"

so I can go

myprogram [Arguments]

Instead of

perl myprogram [Arguments]

If there is no way to do this...would making a bat file (windows) of the same name do 
it?  I'm not sure if a bat file can handle arguments...and if it can, would it be able 
to pass them to my perl program?

I'm new to perl, and I've also never really had cause to learn much about bat files 
either.

-Dave



Re: Telnet

2001-06-20 Thread SAWMaster

Yes and no.  You cannot do it with telnet, but you can get what you want by
using an x-term client and setting up the server box to allow x connections.
One commercial example of an X-Term client for a windows box would be
X-Win32.  Do a search on the net for "X-Win32" and you'll find plenty of
information.  I'm not sure if there's any public domain freeware X-Term
clients.  If anyone knows of one please let me know.


> Hi
>
> Hey can we run KDE or Xwindows by telneting to Linux servers ???
>
> Regards
>
> Joel




DBI problems

2001-06-27 Thread SAWMaster

Hi group!  Just got back from a trip, and I'm a little rusty (a rusty newbie, JOY)

Anyway, before I left I was having trouble inserting new data into my database table, 
and oddly enough, the problem didn't solve itself while I was gone. :(

Here is my current code.  I've been racking my brain, and consulting the various books 
I have on lend from the library, with no success.  It looks right to me!  Can someone 
please help me out?

I'm using Windows 98 with ActiveState Perl on Apache Web server.

use cgi;
use DBI;   

$dbh = DBI->connect('dbi:ODBC:freq');  
DBI->trace( 2, 'errors.txt' ); 
   
$co = new CGI; 

print $co->header, $co -> start_html(title=>'Canadian Online Radio Frequency 
Database'),   
$co->center($co->h1('Thanks using our database!')), $co->h3('Here is what you 
submitted...'),$co->hr;#not done feedback yet   
print $co->hr;
print "Data Added\n";  
   
$newfreq=$co->param('txtFREQ');
$newloc=$co->param('txtLOC');
$newdesc=$co->param('txtDESC');
$newfreqtype=$co->param('txtFREQTYPE');
$newcat=$co->param('txtCAT');
$newcall=$co->param('txtCALL');
$newtx=$co->param('txtTX');
$sqlstatement = "INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) 
VALUES (?,?,?,?,?,?,?)";
$sth = $dbh->prepare($sqlstatement) || die $dbh->errstr;
$sth->execute($newfreq, $newloc, $newdesc, $newfreqtype, $newcat, $newcall, $newtx) || 
die $dbh->errstr;
print "Thank you for submitting a frequency!";
print $co->end_html;



And here is what gets piped out to my errors.txt file.


  DBI 1.14-nothread dispatch trace level set to 2
-> prepare for DBD::ODBC::db (DBI::db=HASH(0x1b38790)~0x1b3a194 'INSERT INTO 
canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES (?,?,?,?,?,?,?)')
dbd_preparse scanned 7 distinct placeholders
dbd_st_prepare'd sql f32113660
 INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES 
(?,?,?,?,?,?,?)
<- prepare= DBI::st=HASH(0x1b38880) at ADDTOF~1.PL line 29.
-> execute for DBD::ODBC::st (DBI::st=HASH(0x1b38880)~0x1b05b08 '11' 'MB' 
'TEST' 'VHF' 'FARM' 'TESTING' '2')
bind 1 <== '11' (attribs: )
bind 1 <== '11' (size 6/7/0, ptype 4, otype 1)
bind 1: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=6.
bind 2 <== 'MB' (attribs: )
bind 2 <== 'MB' (size 2/3/0, ptype 4, otype 1)
bind 2: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=2.
bind 3 <== 'TEST' (attribs: )
bind 3 <== 'TEST' (size 4/5/0, ptype 4, otype 1)
bind 3: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=4.
bind 4 <== 'VHF' (attribs: )
bind 4 <== 'VHF' (size 3/4/0, ptype 4, otype 1)
bind 4: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=3.
bind 5 <== 'FARM' (attribs: )
bind 5 <== 'FARM' (size 4/5/0, ptype 4, otype 1)
bind 5: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=4.
bind 6 <== 'TESTING' (attribs: )
bind 6 <== 'TESTING' (size 7/8/0, ptype 4, otype 1)
bind 6: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=7.
bind 7 <== '2' (attribs: )
bind 7 <== '2' (size 5/6/0, ptype 4, otype 1)
bind 7: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=5.
dbd_st_execute (for sql f32113660 after)...
st_execute/SQLExecute error -1 recorded: [Microsoft][ODBC Microsoft Access Driver] 
Syntax error in INSERT INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)
!! ERROR: -1 '[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT 
INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)'
<- execute= undef at ADDTOF~1.PL line 30.
-> errstr in DBD::_::common for DBD::ODBC::db (DBI::db=HASH(0x1b38790)~0x1b3a194)
<- errstr= ( '[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT 
INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)' ) [1 items] at 
ADDTOF~1.PL line 30.
-- DBI::END
-> disconnect_all for DBD::ODBC::dr (DBI::dr=HASH(0x1b7dda8)~0x1b387e4)
<- disconnect_all= '' at DBI.pm line 450.
-> DESTROY for DBD::ODBC::st (DBI::st=HASH(0x1b05b08)~INNER)
<- DESTROY= undef during global destruction.
-> DESTROY for DBD::ODBC::db (DBI::db=HASH(0x1b3a194)~INNER)
<- DESTROY= undef during global destruction.
-> DESTROY in DBD::_::common for DBD::ODBC::dr (DBI::dr=HASH(0x1b387e4)~INNER)
<- DESTROY= undef during global destruction.




Mysterys of the Unknown STDIN

2001-07-04 Thread SAWMaster

I'm working on a fairly lengthy ( for a newbie like me) program that has two modes.  
The user can type "mine blah" and my program will find all "blah" or he/she can type 
"mine !" to enter interactive mode.  The problem is that when I get to this snippet:

sub getinteractivesearch
{
 #print "We're interactive!\n\n";
 opendir(logdirectory, '.') or die "Can't open directory.";
 print "Enter string to search for: ";
 $searchstring = <>;
 chomp $searchstring;
 print $searchstring;
 &searchfiles; 
}

My program dies with this:

Enter string to search for: Can't open !: No such file or directory at 
C:\PERLPR~1/mine.bat line 46.

So basically it looks like it's skipping the part where is asks for the search string. 
 I have had this problem before, and I have never been able to figure it out.  Is 
there some way to flush the <>?  Or what?  I'm totally in the dark here.  Maybe I'm 
looking in a completely wrong direction.  Can someone be my guide?  If you need more 
code I'd be happy to provide it.  My problem might not even exist in this snippet.

-Dave



Re: Mysteries of the STDIN

2001-07-04 Thread SAWMaster

Paul, yeah the print is there just to help me debug.  Isn't <> the same as ?  
Are you saying I should change that?

Bill, it is a perl file that I used pl2bat to convert to a batch file.  I can run it 
either way, as a .pl or as a .bat...the result is the same.

-Dave



RE: Mysteries of the Unknown STDIN RESOLVED!!

2001-07-04 Thread SAWMaster

Hi group, just wanted to thank all who helped me out with this little problem, 
particularly Paul Johnson who's input ended up being the key to my problem.
I appreciate all of your help!

-Dave



Parent and Current Directories

2001-07-05 Thread SAWMaster

Hello group!

I'm trying to list all files in a directory EXCEPT the current and the parent 
directories.

ie.

.
..
file1
file2
file3

Is not what I want.  I only want:

file1
file2
file3

I thought I had the right code, but I don't.

while($i < ($#filelist))
{
if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))
{
print @filelist[$i];
print "\n";
$i++;
}
}

I was thinking, maybe it's not equal to . and .. because of a newline at the end of . 
and .. ?

But I tried a chop, or chomp and it just took off the last letter of all files, 
problem unsolved.

Can someone steer a newbie in the right direction again?

-Dave




Absolute Path

2001-07-05 Thread SAWMaster

Hi group!

Little bit of background.  I made a perl cgi that scans a directory for files and auto 
generates a html page with hyperlinks to download whatever files are in the directory. 
 I don't
know if there's an easier way to do this than what I did (built it from scratch) but 
I'm doing this to learn Perl, not to make things easy.  I had this working locally 
through 
localhost, using the full path to the files, but it won't work if someone tries to 
access it remotely.  Anyway, on to the problem.

I'm having trouble writting my absolute path for a link to a .zip file in a cgi script.

Here's my code.

while($i < ($#filelist))
{
if ((@filelist[$i] ne '.') && (@filelist[$i] ne '..'))
{
print "@filelist[$i]";
print "\n";
}
$i++;
}

The problem being, that because this file is in my CGI bin, I need to back track to 
the parent directory a few times and then follow another branch of the directory 
structure back out to the ftp directory..

I can't add a C:\ to the front of it because then it can only be accessed locally.

I'm thinking I could use something like 
\\..\\..\\ftp\\public\\downloads\\assortedfiles\\

To backtrack like in Unix, but it doesn't work like I thought it would.  I'm using 
Windows 98 and Apache web server to do this in.  So my cgi-bin is in the standard
c:\program files\apache group\apache\cgi-bin\

My full path to ftp is:

c:\ftp\public\downloads\assortedfiles\

I don't know, I may be on the right track with the Unix style .. and perhaps just 
messed up with my quoting in the script.  Or, I'm completely lost.

Can someone help me?

-Dave




META REFRESHES

2001-07-17 Thread SAWMaster

Can someone tell me why this isn't working on IE?

It works within Opera, I don't know about netscape yet.

print qq~http://mypage.html";>\n~;




Re: META REFRESHES

2001-07-18 Thread SAWMaster

Thank you very much Abdulaziz, it works perfectly.  I did not even know such
a header existed, at first I was confused about what you were trying to say,
but I looked around on the net and found what you meant.

My page works flawlessly now, however I'm still puzzled why my meta refresh
did not work.  It worked in Opera, but not in Internut Exploder and I can't
see why.  I have seen plenty of examples on the web that show this meta
refresh technique being usedand IE is probably the most popular browser
on the web...why would it not support this?  I know you tried to explain
this to me, but I don't follow.

My CGI generates an HTML document does it not?  And the user's browser
interprets that document just like any other web page.  So why would it not
work?

Anyway, as I started off by saying, thank you very much!  It doesn't matter
for my page any longer, I am just curious.

-Dave


- Original Message -
From: Abdulaziz Ghuloum <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 17, 2001 6:43 PM
Subject: Re: META REFRESHES


> Hello,
> Just a question, why are you using a meta if you can pass the header
> directly?  The meta AFAIK is used so that the server adds the appropriate
> lines to the header before sending the document.
>
> 
>
> For example, adding the previous line to your html file will cause the
> server to send "Content-type: text/html; charset=windows-1256" instead of
> the usual "Content-type: text/html".
>
> If however you're using CGI, the server will not add any appropriate
> headers since you're responsible for supplying all the headers from your
> script.  So, adding that last line to a cgi script will be useless.
>
> Same probably applies for your line.  Just add the "Refresh: 5" header to
> your script instead of using the meta.
>
> Hope this helps,,,
>
> Aziz,,,
>
> In article <[EMAIL PROTECTED]>, "Sawmaster"
> <[EMAIL PROTECTED]> wrote:
>
> > Can someone tell me why this isn't working on IE?
> >
> > It works within Opera, I don't know about netscape yet.
> >
> > print qq~http://mypage.html";>\n~;
> >
> >
>
> --
> 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]




Simple one liner problem.

2001-08-22 Thread SAWMaster

I can't seem to use variables like thiswhy not?
Is there a simple way to do this?
Without having to manually do it with an array traversing check/change function?

$workingcopy =~ tr/$lettertochange/$lettertochangeto/g;

I also tried

$workingcopy =~ s/$lettertochange/$lettertochangeto/g;


Thanks

-Dave





Simple on liner problem follow up.

2001-08-22 Thread SAWMaster

Thanks guys, that part now works thanks to all who supported me.

I've run into a similar problem now though in this code:

 print "Select a letter to change to: ";
  $lettertochangeto = ;
  if ($lettertochangeto =~ m/$workingcopy/i)#PROBLEM LINE I THINK
  {
   print "That letter is already being used, try again.";
   &manual;
  }
  else
  {
   eval "\$workingcopy =~ tr/$lettertochange/$lettertochangeto/";
   #$workingcopy =~ tr/$lettertochange/$lettertochangeto/g;
   print "$cryptogram\nchanged to\n\n$workingcopy\n";
   &manual; 
  }


I assumed that this problem was the same as before so I tried the things you suggested 
again, but they did not seem to work this time, so I have reverted it back to what I 
assumed would have been sufficient, just so that any explanations you might have for 
me will start at the basics.


Thanks in advance,

-Dave



ANSIScreen

2001-08-24 Thread SAWMaster

Can someone tell me if ANSIScreen works under windows98?

I have the module installed, but instead of color showing up in my program, I seem to 
get some kind of color code.

Ex.

This text is bold blue.




ANSIColor

2001-08-24 Thread SAWMaster

ANSIColor, and ANSIScreen are both installed, if color doesn't work, will any of the 
screen stuff work either?



Premature end of script headers

2001-09-19 Thread SAWMaster

What is wrong with this line?

print qq~\n~;


Some reserved word in there?

The error is "Premature end of script headersif that helps.

If I take that line out it works fine (CGI wise, not HTML wise)

Can someone help me?

-Dave



DBI limitations

2001-09-19 Thread SAWMaster

Hello, can someone tell me why DBI can only handle 6 fields?  I have a data base table 
that has more than 6, and I don't know how I'm going to accommodate it all in my cgi 
script.  I'm new at this.




DBI Limitations Urgent

2001-09-20 Thread SAWMaster

I'm not sure what you mean by DBD, but in case I'm right...lol

I'm using MS Access from Office 97 on a Windows 98 server running Apache.

My code works fine unless I go over 6 in my select statement ie.:

$sqlstatement="SELECT pid, name, description, picture, price, sold FROM
gallery ORDER BY pid";

What I want to do is split the picture field into two fields...one for the
big picture one for the smaller thumbnail picture.  But not just limited to
that...I'd like to have room to expand the database in case I need to.

Thanks for your help.

-Dave


###CODE###

#!c:\perl\bin\perl -w

use DBI;
$dbh = DBI->connect('dbi:ODBC:gallery'); 
print "Content-type: text/html\n\n";
print qq~~;
print qq~\n~; 
print qq~\n~;  
#print qq~\nOnline Gallery\n\n~;


$sqlstatement="SELECT pid, name, description, picture, price, sold FROM gallery ORDER 
BY pid";
$sth = $dbh->prepare($sqlstatement);  
$sth->execute || die "Could not execute SQL statement ... maybe invalid?";


print qq~\n~;
print qq~\n~;
while (@row=$sth->fetchrow_array)
{
 print qq~$row[3]Product ID: $row[0]\n~;
 print qq~Product name: $row[1]\n~;
 print qq~Description: $row[2]\n~;
 print qq~Price: \$~;
 printf "%.2f", $row[4];
 print qq~ ~;
 print qq~\n~;
 if ($row[5] == 1)
 {
  $sold = "yes";
 }
 print qq~BUY\n~;
 if ($row[5] == 1)
 {
  print qq~SOLD OUT\n~;
 }
 else
 {
  print qq~FOR SALE\n~;
 }
 print qq~\n~;
 $sold = "no";
}
print qq~\n~;
print qq~\n~;
print qq~\n~;
print qq~\n~;


- Original Message -
From: Mel Matsuoka <[EMAIL PROTECTED]>
To: SAWMaster <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 10:56 AM
Subject: Re: DBI limitations


> At 03:34 PM 09/19/2001 -0500, SAWMaster wrote:
> >Hello, can someone tell me why DBI can only handle 6 fields?
>
> No, because it can handle much more than 6 fields :)
>
> >I have a data base table that has more than 6, and I don't
> >know how I'm going to accommodate it all in my cgi script.
>
> Please show us your code so we can help you better. I have used DBI for
> everything as simple as a 3 field table all the way up to a ridiculous 20
> field table, so your problem is almost certainly an issue with errors in
> your Perl code, and not DBI itself.
>
> What DBD are you using, btw?
>
> Aloha,
> mel
>
>
>
> --
> mel matsuokaHawaiian Image Productions
> Chief Executive Alphageek  (vox)1.808.531.5474
> [EMAIL PROTECTED]  (fax)1.808.526.4040
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>




Getting frustrated. DBI Access 97 issues.

2001-10-02 Thread SAWMaster

Hello group.

I need someone who has a lot of experience to help me...possibly on an on going basis 
because I have asked for help on this issue before to no avail.

Everyone says that it looks right...but it is not right.  Something is wrong.

When I click the link (with a freshly erased browser cache) to this CGI script, it 
seems to run fine.  I get a complete page, but when I click "refresh" it starts 
perl...and then crashes.


"
Perl

This program has performed an illegal operation and will be shut down.

If the problem persists, contact the program vendor.
"

I thought maybe it was a bug in active state perl, so I upgraded to the most recent 
release.  That did not help.

I though that maybe it was a bug in the DBM module.  I upgraded to the latest release. 
 That did not help.

I am not seeing any errors showing up in my apache error log.

I really need help with this.  Can someone please help?

I have 3 scripts with the same problem.  They are identical except for the SQL 
statements, so I'll only post one.

#!c:\perl\bin\perl -w

use DBI;
$dbh = DBI->connect('dbi:ODBC:gallery');
$sqlstatement="SELECT name, artist, picture, price, sold, pid, description FROM 
gallery ORDER BY pid";
$sth = $dbh->prepare($sqlstatement);  
$sth->execute || die "Could not execute SQL statement ... maybe invalid?";

print "Content-type: text/html\n\n";
print qq~\n~;
print qq~\n~; 
print qq~\n~;  

print qq~\n~;
print qq~\n~;

while (@row=$sth->fetchrow_array)
{
 print qq~\n\n\n~;
 print qq~\n~;
 print qq~http://localhost:8080/wholesalegallery/galleryphotos/fullsize/~;
 print qq~$row[2].jpg~;
 print qq~">http://localhost:8080/wholesalegallery/galleryphotos/thumbs/$row[2]~;
 print qq~.jpg">\n~;
 print qq~Product name: $row[0]\n~;
 print qq~Description: $row[6]\n~;
 print qq~Artist: $row[1]\n~;
 print qq~Price: \$~;
 printf "%.2f", $row[3];
 print qq~\n~;
 if ($row[4] == 1)
 {
  print qq~SOLD\n~;
  print qq~\n~;
 }
 else
 {
  print qq~FOR SALE\n~;
  print qq~BUY \n~;
 }
 print qq~\n~;
}

print qq~\n~;
print qq~\n~;
print qq~\n~;
print qq~\n~;
print qq~\n~;  


My system is a PII-300 mhz with 96 megs ram.

Windows 98

ActiveState Perl

Apache Web Server

Please ignore my ugly code.  I'm new and I just want to get this going before I worry 
about making it "beautiful".

And while you're looking at it.  Is there a way to pass the NAME (not the value) of 
the "buy" checkbox to another cgi script?

Thanks for your help.



Content Type

2001-10-19 Thread SAWMaster

Hello, I have a script that is acting funny.

I have this line in it:

$addtocart_co->header(-cookie=>$pid_cookie);

Does that line not handle the content type as well?

I get "premature end of script headers" with just that.

But if I add this line:

print "Content-type: text/html\n\n";

It works, although that line is printed on the actual page.

I thought the first line handled content type too, but I guess I was wrong?  What do I 
need to add to have this work the way I want?

Can someone help a confused newbie?

Thanks,

-Dave




Re: Content Type

2001-10-19 Thread SAWMaster


> Yes.  You did print out the return value, didn't you?  The header method
of
> CGI.pm doesn't print the header out, it returns it; you have to print it
out
> yourself.

No I didn't, I did not know I needed to.  It works great now thanks AGAIN!

-Dave

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




Concatination

2001-10-23 Thread SAWMaster

Hello group.  I am getting an error in my apache logs that is not clear to me what 
exactly is wrong.

I get the same error in different scripts, and completely different lines, so I'll 
just post one and hopefully once I know how to fix this one, I can fix the rest.

Line 27:

$cookie = $addtocart_co->cookie(-name=>'incart', -value=>$pid . ":" . $pidsincart, 
-expires=>'+1h');
print


$cookie, $pid, and $pidsincart are all predefined with values.

I get the error:

Use of uninitialized value in concatenation (.) or string at 
c:\PROGRA~1\APACHE~1\APACHE\CGI-BIN\ADDTOC~1.PL line 27.

It doesn't impact my program in any way I've seen so far, but it's annoying because it 
fills my apache logs unnecessarily.

Thanks for any help!

-Dave



Commenting.

2001-10-24 Thread SAWMaster

Is there a way to "block comment" in Perl?

My book only covers using # to comment individual lines.

Is there a symbol I can use to comment out entire sections of code for the debugging 
process?




Premature end of script headers FRUSTRATION

2001-11-01 Thread SAWMaster

Hello again group.

I've been stareing at this for ages trying to figure out why it's not working, I can't 
see why it's not.

Am I blind?
I think my trouble is in the very last section.  What I'm trying to do is when a user 
hits "back" after clicking an item to put in his/her cart, the button is still visable 
and functional from before, until they hit refresh, or the page automatically 
refreshes, so they can actually hit it again and buy the same item they just bought 
TWICE.  I can't have this, so I'm trying to check the current state of the database 
and make sure that they have not attempted to put an item into their cart that is 
already in someone's cart (likely their own).  Each product is unique, so there will 
never be a case of a user needing duplicate items.

A "1" value in the "sold" field indicates that the product HAS BEEN sold.

I hope I'm being clear.

I hope someone can help.

I thank you in advance.

-Dave





use CGI;
use DBI;

$addtocart_co = new CGI;
$dbh = DBI->connect('dbi:ODBC:gallery');
$dbh2 = DBI->connect('dbi:ODBC:gallery');

$pid = $addtocart_co->param("selected");

$sqlstatement = "UPDATE gallery SET sold = '1' WHERE pid = $pid";
$sth = $dbh->prepare($sqlstatement);  
$sth->execute || die "Could not execute SQL statement ... maybe invalid?";

##COMMENT
#if(0)
#{
$sqlstatement2 = "SELECT pid, sold FROM gallery ORDER BY pid";
$sth2 = $dbh2->prepare($sqlstatement2);  
$sth2->execute || die "Could not execute SQL statement ... maybe invalid?";
#}

##Need code to check if product has been added already.  (Getting duplicate pids in my 
cookies)

$pidsincart = $addtocart_co->cookie(-name=>'incart');

$cookie = $addtocart_co->cookie(-name=>'incart', -value=>" " . $pid . ":" . 
$pidsincart . " ", -expires=>'+1h');
print

$addtocart_co->header(-cookie=>$cookie);
print qq~\n~;
print qq~\n~; 
print qq~\n~;

##COMMENT
#if(0)
#{

$done = 0;
while (@row=$sth2->fetchrow_array)
{
 if (($row[0] == $pid) && ($row[1] == 1) && ($done == 0))
 {
  print qq~Product has been sold already, select a different product.\n~;
  print qq~\n~;
  print qq~\n~;
  $done = 1;
 }
 if ($done == 0)
 {
  print qq~Item $pid has been placed in your shopping cart. CLICK HERE TO VIEW CART CONTENTS\n~;
  print qq~\n~;
  print qq~\n~;
  $done = 1;
 }
}

#}