473,466 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can't update database in CGI,PERL,DBI,ORACLE

1 New Member
Please could someone help,

I have a Perl cgi script which works perfectly when run in a dos prompt, it connects to a database on my laptop and inserts a record. But when I use the internet browser to run the script it doesn't insert the record in the database or display any messages past the following line.

$dbh=DBI->connect("DBI:Oracle:testdb",'alan', 'alan');

I have supplied the whole script below

As you can see, it takes input from a previous web page and should insert the input straight into the database, it does on dos, running the command perl history.cgi
Expand|Select|Wrap|Line Numbers
  1. #!c:\perl\bin\perl -w
  2.  
  3. ####################################################
  4. # This procedure is used Add new notes           ###
  5. # Alan Taylor Feb 06                             ###
  6. ####################################################
  7.  
  8. use CGI;
  9. use CGI::Carp; 
  10.  
  11. use DBI;
  12.  
  13.  
  14. $query = new CGI;
  15. print $query->header;
  16. print $query->start_html;
  17.     $h1=$query -> param ("heading");
  18.       $note=$query->param('note');
  19.     # ($note = $note) =~ s/\n/\n<BR>/g;
  20. #      $selected=$query->param ("B1");
  21.  
  22. $h1="test";$note="test heading"; # used to forced input when testing in dos
  23.  
  24. # Check for Blank Entry
  25.  
  26. if ( $h1 eq "" || $note eq "" ) {
  27.  
  28. print <<EOF;
  29.  
  30. <html>
  31.  
  32. <head>
  33. <meta http-equiv="Content-Language" content="en-gb">
  34. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  35. <title>Error</title>
  36. </head>
  37.  
  38. <body>
  39.  
  40. <p align="center"><b><font size="6" color="#FF0000">Error</font></b></p>
  41. <p align="center"><b>Invalid Entry</b></p>
  42. <p align="center"><font color="#000080">Please note you can not enter a null 
  43. heading or note</font></p>
  44. <form action="http://localhost/addnewnotetodatabase.htm" method="GET" >
  45. <p align="center"><input type="submit" value="Re-Enter Data" name="B3"></p>
  46. </form>
  47. <p align="center">&nbsp;</p>
  48.  
  49. </body>
  50.  
  51. </html>
  52.  
  53. EOF
  54.  
  55.  
  56.     open (OUTPUT, ">c:/Inetpub/web/data.txt");
  57.     print OUTPUT ($h1);print OUTPUT ("alankingtaylor"); # crazy name :-)
  58.     print OUTPUT ($note);print OUTPUT ("alankingtaylor");
  59.     close (OUTPUT);
  60.  
  61. # Set Vars
  62.  
  63. open FH, "<c:/Inetpub/web/data.txt" or die "Unable to open data.txt: $!";
  64.     $in=<FH>;
  65. my ($title,$note) = split (/alankingtaylor/, $in);
  66. close FH;
  67.  
  68. print $title;print $note;
  69.  
  70.  
  71. # Connect to Database
  72. $dbh=DBI->connect("DBI:Oracle:testdb",'alan', 'alan');
  73. $sth = $dbh->prepare_cached("INSERT INTO alan.notes (title,note) VALUES ('$title','$note')");
  74. $sth->execute();  
  75. print "done";  
  76.  
  77. print $query->end_html;
Feb 15 '06 #1
1 4658
eWish
971 Recognized Expert Contributor
I must assume that you got your issue resolved. For others that might have a similar problem you should always use the strict and warnings pragmas. You could also have the error print to the screen using the following.

Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw/fatalsToBrowser/;
--Kevin
Nov 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
3
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
4
by: Don | last post by:
Hi, I am moving from Sybase to Oracle and I used to be able to do update statement like this in Sybase: UPDATE TABLE1 SET T1.field1 = T2.field2 FROM TABLE1 T1, TABLE2 T2 WHERE T1.field2...
0
by: Piotr B. | last post by:
Hello, I want to make use of a Perl script "ora2pg" (Oracle to PostgreSQL schema converter), which requires the following modules: DBI, DBD::Oracle and DBD::Pg. As I don't use Perl on a...
3
by: intl04 | last post by:
I was told by an instructor of Oracle SQL that an MS Access database cannot be used to have several people enter records at about the same time, that the database will "freeze up" as a result -...
20
by: antonberg1 | last post by:
Hi, I wonder if it is possible to write a platform independent c-application running as job on a sun solaris multiprocessor machine, connecting to an oracle database and creating a very simple...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
0
by: richat | last post by:
hi everyone ,i hav this problm that this code doesn't insert data into the database. It says that active perl not installed or some error in the code .plz help me out .Its urgent. ...
1
by: Master Ken | last post by:
Hi All, I'm very new to C# and ASP and I am asking for some help as I don't really know where to start on this project. Some background info first I run a report each week which outputs data...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.