shalomgod has asked for the wisdom of the Perl Monks concerning the following question:
The output i get is#!/usr/bin/perl -w use CGI; use strict; use DBI; my $query = new CGI->new(); print $query->header("text/html"), $query->start_html(-title => "Database Test"), $query->h1("Database Test"), my $user = $query->param("username"), my $db_handle = DBI->connect("dbi:mysql:database=test;host=localhost; +user=root;") or die "Couldn't connect to database: $DBI::errstr\n"; my $sql = "SELECT * FROM users WHERE id = '$user'"; my $statement = $db_handle->prepare($sql) or die "Couldn't prepare query '$sql': $DBI::errstr\n"; $statement->execute() or die "Couldn't execute query '$sql': $DBI::errstr\n"; while (my $row_ref = $statement->fetchrow_hashref()) { print "<b>$row_ref->{email}</b>" ; } $db_handle->disconnect(); print "<h1>Database Test</h1>"; $query->end_html;
if i change:Database Test (Username i enter in the form)DBI::db=HASH(0x838242c) Database Test
tomy $sql = "SELECT * FROM users WHERE id = '$user'";
then I will getmy $sql = "SELECT * FROM users WHERE id = 1";
the error i get when i run it isDatabase Test (Correct email address) Database Test
line 27 being the sql statement. What can I do to use form data in my sql queries @_@ any help is much appreciated.Use of uninitialized value in concatenation (.) or string at login.pl +line 27.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dealing with uninitialized values
by grep (Monsignor) on Oct 14, 2006 at 01:25 UTC | |
by driver8 (Scribe) on Oct 14, 2006 at 09:39 UTC | |
|
Re: Dealing with uninitialized values
by ikegami (Patriarch) on Oct 14, 2006 at 07:34 UTC | |
|
Re: Dealing with uninitialized values
by chorny (Scribe) on Oct 14, 2006 at 07:38 UTC | |
|
Re: Dealing with uninitialized values
by fenLisesi (Priest) on Oct 14, 2006 at 08:03 UTC | |
|
Re: Dealing with uninitialized values
by chromatic (Archbishop) on Oct 14, 2006 at 07:34 UTC | |
|
Re: Dealing with uninitialized values
by gam3 (Curate) on Oct 15, 2006 at 09:48 UTC |