Article View: bit.databases.mssql-l
Article #134mSQL program
From: Peekay
Date: Wed, 11 Oct 2000 00:00
Date: Wed, 11 Oct 2000 00:00
52 lines
1979 bytes
1979 bytes
I hope this is the right place to post - I have a problem with mSQL
which I'm sure is just due to something silly which as someone new to
mSQL I have just missed out.
I'm trying to write a program, as below, which takes info from a form
and checks a table to see if the userid has been created before.
The program runs through ok and prints out the HTML at the end, but
when I re-run the program it does exactly the same - though it should
show a different page (the else info that is missing from the below)
as the user has already been entered into the dbase.
Help!
PK
#!/usr/bin/perl
use strict;
use CGI;
use Msql;
my $qr = new CGI;
my $qo = new CGI;
$qr->import_names( "res" );
my $usertemp = $res::userid;
my $db = Msql->connect;
$db->selectdb('emcdbase');
my $sq = "SELECT userid FROM personaldata WHERE userid = $res::userid
";
my $output = $db->query($sq);
my @values = $output->fetchrow;
if ($values[0] ne $usertemp)
{
my $outputed = $db->query("INSERT INTO personaldata (userid, fname,
sname, address1, address2, town, county, pcode, country, phone) VALUES
( $res::userid, $res::fname, $res::sname, $res::address1,
$res::address2, $res::town, $res::town, $res::county, $res::pcode,
$res::country, $res::phone");
my $created = $db->query("SELECT userid FROM personaldata WHERE userid
= $usertemp ");
my $person = $created->as_string;
print <<END_OF_MESSAGE;
Content-type: text/html
# Rest of HTML deleted
Technical Details
Message-ID:
<39e44837.176324548@news.dircon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f6611,be234851ef15282b,start X-Google-Attributes: gidf6611,public From: nospam-peekay@dircon.co.uk (Peekay) Subject: mSQL program Date: 2000/10/11 Message-ID: <39e44837.176324548@news.dircon.co.uk> X-Deja-AN: 680106663 X-Trace: news.dircon.co.uk 971265502 194.112.52.240 (Wed, 11 Oct 2000 12:58:22 BST) NNTP-Posting-Date: Wed, 11 Oct 2000 12:58:22 BST Newsgroups: bit.databases.mssql-l X-Complaints-To: news-admin@dircon.co.uk