Re: MySQL with perl error
hallo! With reference to Dawn H on 04.07 00:36: > The error log says, > > Can't call method "do: on an undefined value. . . > > But the EXACT SAME code works on another script I'm running. I don't see any > reason for it to suddenly have a problem. What does this error message MEAN? > > Code Snippet-- > # Form was okay; get image type and contents and create new record. > # Use REPLACE to clobber any old image with the same name. > > $mime_type = uploadInfo ($image)->{'Content-Type'}; > ($full, $thumb) = read_image_file ($image); > $dbh->do ("REPLACE INTO image > (name,listing_id,image,thumbnail,mime_type) > VALUES(?,?,?,?,?)", > undef, > $name, $listing_id, $full, $thumb, $mime_type) > or bail_out("There's a problem with the upload"); i have it with (). like ($name), ($listing_id), ... > -End Snippet--- > > http://www.rdcss.com/ - R&D Computer Solutions > http://wow.cooncheese.com/ - WOW.CoonCheese.com > http://dpenguin.rdcss.com/ - Cornucopia > Filter fixer: database,sql,query > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- Gruß & bye Michael Ott - - Siemens AG - I&S IT PS 51 ERL - - Werner-von-Siemens-Strasse 60 - - 91050 Erlangen- - Tel. +49 91 31 7 42 0 54 - - [EMAIL PROTECTED] - - open-source and you have much fun - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MySQL with perl error
The only reason why that might happen (assuming it is working somewhere else), the object isn't return. So connect() constructor couldn't return the object. To read the error message from DBI, you'll have to read $DBI::errstr: my $dbh = DBI->connect(dsn, login, password) or die $DBI::errstr; If the program passes the above line without errors, you'll not have that error message. another way of doing the above is: my $dbh = DBI->connect(dsn, login, password, {RaiseError=>}); Sent on Jul 4 by Dawn H to [EMAIL PROTECTED] dpengu> The error log says, dpengu> dpengu> Can't call method "do: on an undefined value. . . dpengu> dpengu> But the EXACT SAME code works on another script I'm running. I don't see any dpengu> reason for it to suddenly have a problem. What does this error message MEAN? dpengu> dpengu> Code Snippet-- dpengu> # Form was okay; get image type and contents and create new record. dpengu> # Use REPLACE to clobber any old image with the same name. dpengu> dpengu> $mime_type = uploadInfo ($image)->{'Content-Type'}; dpengu> ($full, $thumb) = read_image_file ($image); dpengu> $dbh->do ("REPLACE INTO image dpengu> (name,listing_id,image,thumbnail,mime_type) dpengu> VALUES(?,?,?,?,?)", dpengu> undef, dpengu> $name, $listing_id, $full, $thumb, $mime_type) dpengu> or bail_out("There's a problem with the upload"); dpengu> -End Snippet--- dpengu> dpengu> http://www.rdcss.com/ - R&D Computer Solutions dpengu> http://wow.cooncheese.com/ - WOW.CoonCheese.com dpengu> http://dpenguin.rdcss.com/ - Cornucopia dpengu> Filter fixer: database,sql,query dpengu> dpengu> dpengu> - dpengu> Before posting, please check: dpengu>http://www.mysql.com/manual.php (the manual) dpengu>http://lists.mysql.com/ (the list archive) dpengu> dpengu> To request this thread, e-mail <[EMAIL PROTECTED]> dpengu> To unsubscribe, e-mail <[EMAIL PROTECTED]> dpengu> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php dpengu> -- Sherzod Ruzmetov [EMAIL PROTECTED] http://www.ultracgis.com/sherzodR - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MySQL with perl error
The error log says, Can't call method "do: on an undefined value. . . But the EXACT SAME code works on another script I'm running. I don't see any reason for it to suddenly have a problem. What does this error message MEAN? Code Snippet-- # Form was okay; get image type and contents and create new record. # Use REPLACE to clobber any old image with the same name. $mime_type = uploadInfo ($image)->{'Content-Type'}; ($full, $thumb) = read_image_file ($image); $dbh->do ("REPLACE INTO image (name,listing_id,image,thumbnail,mime_type) VALUES(?,?,?,?,?)", undef, $name, $listing_id, $full, $thumb, $mime_type) or bail_out("There's a problem with the upload"); -End Snippet--- http://www.rdcss.com/ - R&D Computer Solutions http://wow.cooncheese.com/ - WOW.CoonCheese.com http://dpenguin.rdcss.com/ - Cornucopia Filter fixer: database,sql,query - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL with perl
I've encountered this several times. When on the web I just use redirect pages. I'll submit the data to a page that puts the information into the database, and then puts a header() call to redirect them to the real finishing page, passing any minor variables I may need. This way also has the unique ability that you can go back and forth in the browser all you want (no back button woes). - Original Message - From: "Pete Kuczynski" <[EMAIL PROTECTED]> To: "MySQL Email List" <[EMAIL PROTECTED]> Sent: Thursday, June 07, 2001 8:32 AM Subject: Re: MySQL with perl > I overcame this by adding to my php script, something that goves the > user the results, summerised, of what they added to the database, thus > when hitting refresh, it just refreshes the results of what the php > script returned, not what they submitted. > My php script is below. > Pete > > > > require("fedb.inc"); > > mysql_connect(localhost,$user,$password); > > @mysql_select_db($db) or die( "Unable to select database"); > > /*Insert into database */ > > > mysql_query ("INSERT INTO asset (site_id, hostname, device, model, > serial, ip, >dept, mhz, ram, hd_size, os_ver, status, data_port, > pp_port, hub_port, >digi_port, csmim_port, tprmim_port, xyplex_port, > comments, fe) > VALUES ('$site_id', '$hostname', '$device', > '$model', '$serial', '$ip', > '$dept', '$mhz', '$ram', '$hd_size', > '$os_ver', '$status', > '$data_port', '$pp_port', '$hub_port', > '$digi_port', > '$csmim_port', '$tprmim_port', > '$xyplex_port', > '$comments', '$fe') > "); > > > > > print ($site_id); > print (" "); > > > > print ($hostname); > print (" "); > > > > print ($device); > print (" "); > > > print ($model); > > print (" "); > > print ($serial); > > print (" "); > > print ($ip); > > print (" "); > > print ($dept); > > print (" "); > > print ($mhz); > > print (" "); > > print ($ram); > > print (" "); > > print ($hd_size); > > print (" "); > > print ($os_ver); > > print (" "); > > print ($status); > > print (" "); > > print ($data_port); > > print (" "); > > print ($pp_port); > > print (" "); > > print ($hub_port); > > print (" "); > > print ($digi_port); > > print (" "); > > print ($csmim_port); > > print (" "); > > print ($tprmim_port); > > print (" "); > > print ($xyplex_port); > > print (" "); > > print ($comments); > > print (" "); > > print ($fe); > > print (" "); > > print (""); > > print (""); > > print ("Thanks for submitting your device."); > > > > ?> > > Home | > Search Item | > Search Site | > Update | > Delete > > > > > > > > Cindy wrote: > > > > "Dawn H" writes: > > >I've written a couple of scripts and have a thing that I haven't quite > > >figured out. If anyone can shed light on this, I'd appreciate it. > > > > > >When a person submits a form that inserts a record into the database, if > > >they then refresh the page that comes up after the submit, the record will > > >be submitted a second time. I suppose this is due to the fact that the > > >subroutine that is called with the submit contains both the write to > > >database bit and the view bit. So refreshing causes a repeat of both items. > > > > > >How can I do this without that problem? > > > > I was finally forced to add a check that there wasn't already an > > identical record (using a minimum comparison set of fields) before > > inserting the record. There really isn't any way
Re: MySQL with perl
I overcame this by adding to my php script, something that goves the user the results, summerised, of what they added to the database, thus when hitting refresh, it just refreshes the results of what the php script returned, not what they submitted. My php script is below. Pete "); print (""); print ("Thanks for submitting your device."); ?> Home | Search Item | Search Site | Update | Delete Cindy wrote: > > "Dawn H" writes: > >I've written a couple of scripts and have a thing that I haven't quite > >figured out. If anyone can shed light on this, I'd appreciate it. > > > >When a person submits a form that inserts a record into the database, if > >they then refresh the page that comes up after the submit, the record will > >be submitted a second time. I suppose this is due to the fact that the > >subroutine that is called with the submit contains both the write to > >database bit and the view bit. So refreshing causes a repeat of both items. > > > >How can I do this without that problem? > > I was finally forced to add a check that there wasn't already an > identical record (using a minimum comparison set of fields) before > inserting the record. There really isn't any way to prevent dingbats > from refreshing, so... I CYA by emailing a copy of the record/element > values to myself when I refuse to add it in, but I havne't had any > spurious refusals so far. > > --Cindy > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- ___ Pete Kuczynski Principal Field Engineer DHL Airways Inc. Infrastructure Technology & Services (773)-462-9758 24/7 Helpdesk 1-800-434-5767 - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL with perl
OTOH, if you use mod_perl, *all* scripts are cached. That way you can have a single script per function, which makes each smaller and simpler to debug. Paul Wilson iiNet Ltd > Cindy, read my reply to this. You are mistaken. There is actually a way > to make a single script do all kinds of different operations. I have > single scripts that show a list of records, add a new record, update a > record, and delete a record, all in the same script. This is more > efficient to do because if the webserver is configured correctly, it will > cache the script thereby preventing re-compilation of the script code. > > -Ken > > At 12:18 AM 6/6/01 -0700, Cindy wrote: > > >"Dawn H" writes: > > >I've written a couple of scripts and have a thing that I haven't quite > > >figured out. If anyone can shed light on this, I'd appreciate it. > > > > > >When a person submits a form that inserts a record into the database, if > > >they then refresh the page that comes up after the submit, the record will > > >be submitted a second time. I suppose this is due to the fact that the > > >subroutine that is called with the submit contains both the write to > > >database bit and the view bit. So refreshing causes a repeat of both items. > > > > > >How can I do this without that problem? > > > >I was finally forced to add a check that there wasn't already an > >identical record (using a minimum comparison set of fields) before > >inserting the record. There really isn't any way to prevent dingbats > >from refreshing, so... I CYA by emailing a copy of the record/element > >values to myself when I refuse to add it in, but I havne't had any > >spurious refusals so far. > > > >--Cindy > > > >- > >Before posting, please check: > >http://www.mysql.com/manual.php (the manual) > >http://lists.mysql.com/ (the list archive) > > > >To request this thread, e-mail <[EMAIL PROTECTED]> > >To unsubscribe, e-mail > ><[EMAIL PROTECTED]> > >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL with perl
Cindy, read my reply to this. You are mistaken. There is actually a way to make a single script do all kinds of different operations. I have single scripts that show a list of records, add a new record, update a record, and delete a record, all in the same script. This is more efficient to do because if the webserver is configured correctly, it will cache the script thereby preventing re-compilation of the script code. -Ken At 12:18 AM 6/6/01 -0700, Cindy wrote: >"Dawn H" writes: > >I've written a couple of scripts and have a thing that I haven't quite > >figured out. If anyone can shed light on this, I'd appreciate it. > > > >When a person submits a form that inserts a record into the database, if > >they then refresh the page that comes up after the submit, the record will > >be submitted a second time. I suppose this is due to the fact that the > >subroutine that is called with the submit contains both the write to > >database bit and the view bit. So refreshing causes a repeat of both items. > > > >How can I do this without that problem? > >I was finally forced to add a check that there wasn't already an >identical record (using a minimum comparison set of fields) before >inserting the record. There really isn't any way to prevent dingbats >from refreshing, so... I CYA by emailing a copy of the record/element >values to myself when I refuse to add it in, but I havne't had any >spurious refusals so far. > >--Cindy > >- >Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > >To request this thread, e-mail <[EMAIL PROTECTED]> >To unsubscribe, e-mail ><[EMAIL PROTECTED]> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL with perl
You need to have your script operate in different modes. You do this by passing an argument when you call your script to tell the script what it is supposed to do. So in this case, if the script is called with out any arguments, it will display the form, as follows: http://www.sample.com/sample.pl Then, in your HTML, add a hidden field to your form that provides the action you want to do like this: Now, when you enter the Perl script again, and you extract the parameters, you will have a parameter called "action" that has a value of 1. Do a conditional test for this value, and if the value is not assigned, as in the original case, just display the form. If the action is set to 1, do your database update, and then show the form again with the new values. If the user hits the reload button, the page will reload, but the action will not be set causing the page to show with first doing a reset. Only if they hit the submit button will the hidden variable be passed to the script causing the action value to be set. Hope this helps. BTW, all this stuff you are wanting to do is MUCH MUCH MUCH easier in PHP which is quite Perl like is some respects, but is so much easier and more efficient, and it works GREAT with MySQL because is has a bunch of MySQL functions built in. Most top web applications these days are developed around what is called LAMP, which stands for Linux/Apache/MySQL/PHP. This is the winning combination. -Ken At 01:42 AM 6/6/01 -0500, Dawn H wrote: >I've written a couple of scripts and have a thing that I haven't quite >figured out. If anyone can shed light on this, I'd appreciate it. > >When a person submits a form that inserts a record into the database, if >they then refresh the page that comes up after the submit, the record will >be submitted a second time. I suppose this is due to the fact that the >subroutine that is called with the submit contains both the write to >database bit and the view bit. So refreshing causes a repeat of both items. > >How can I do this without that problem? > >Thanks in advance, >Dawn H >It's practically impossible to look at a penguin and feel angry. --Joe Moore > > >http://www.rdcss.com/ - R&D Computer Solutions >http://wow.cooncheese.com/ - WOW.CoonCheese.com >http://dpenguin.rdcss.com/ - Cornucopia > > >- >Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > >To request this thread, e-mail <[EMAIL PROTECTED]> >To unsubscribe, e-mail ><[EMAIL PROTECTED]> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL with perl
> When a person submits a form that inserts a record into the database, if > they then refresh the page that comes up after the submit, the record will > be submitted a second time. I suppose this is due to the fact that the > subroutine that is called with the submit contains both the write to > database bit and the view bit. So refreshing causes a repeat of both items. > > How can I do this without that problem? > > Thanks in advance, > Dawn H Two possible suggestions: 1) Provide a unique index field and catch the duplicate error if they try to resubmit the form. Then you can send them a nice "Don't do that!" message. 2) After the form is submitted redirect them to a second "Thanks!" page. They can reload that page all they want. Pete -- http://www.elbnet.com ELB Internet Services, Inc. Web Design, Computer Consulting, Internet Hosting - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: MySQL with perl
"Dawn H" writes: >I've written a couple of scripts and have a thing that I haven't quite >figured out. If anyone can shed light on this, I'd appreciate it. > >When a person submits a form that inserts a record into the database, if >they then refresh the page that comes up after the submit, the record will >be submitted a second time. I suppose this is due to the fact that the >subroutine that is called with the submit contains both the write to >database bit and the view bit. So refreshing causes a repeat of both items. > >How can I do this without that problem? I was finally forced to add a check that there wasn't already an identical record (using a minimum comparison set of fields) before inserting the record. There really isn't any way to prevent dingbats from refreshing, so... I CYA by emailing a copy of the record/element values to myself when I refuse to add it in, but I havne't had any spurious refusals so far. --Cindy - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php