ginda has asked for the wisdom of the Perl Monks concerning the following question:
Trying to do this for a university project, any help would be great thanks all#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use vars qw($Query $Query2 $dbh $sth $Value $Data1 $Data2); my @results; my @row; use DBI; $Query = new CGI( ); $dbh = DBI->connect("DBI:mysql:exelstock") or die "Cannot connect: " . $DBI::errstr; $Data1 = $Query->param('Value4'); $Data2 = $Query->param('Value5'); $sth = $dbh->prepare("INSERT INTO walstock (sid, name, qty) VALUES (DE +FAULT, $Data1, $Data2)"); $sth->execute(); print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<BODY>\n"; print "<HEAD><TITLE>Insert Records</TITLE></HEAD>\n"; $sth = $dbh->prepare("SELECT * FROM walstock WHERE name='$Data1'"); $sth->execute(); while (@row = $sth->fetchrow_array) { print "@row\n"; } $sth = $sth->finish(); $dbh->disconnect(); print "</BODY>\n"; print "</HTML>\n";
Edited by Chady -- added code tags.
2005-03-21 Edited by Arunbear: Changed title from 'Was working but now this part doesnt', as per Monastery guidelines
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems inserting values in mysql database
by brian_d_foy (Abbot) on Mar 19, 2005 at 05:24 UTC | |
|
Re: Problems inserting values in mysql database
by cowboy (Friar) on Mar 19, 2005 at 05:32 UTC | |
by chas (Priest) on Mar 19, 2005 at 05:38 UTC | |
by cowboy (Friar) on Mar 19, 2005 at 05:45 UTC | |
by ginda (Initiate) on Mar 19, 2005 at 16:19 UTC | |
|
Re: Problems inserting values in mysql database
by chas (Priest) on Mar 19, 2005 at 05:32 UTC |