MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Ronald Beck Date:August 19 1999 2:14pm
Subject:Re: statement can't work
View as plain text  
I would try the following...

$statement='select * from table where (id=\'12345\') and
(email=\'email@stripped\')';

I would also suggest the following line directly under your
$statement... line:

print "$statementn\n";

to troubleshoot your program.  This will show you exactly what the
$statement variable looks like before the query is made.  My bet is that
$statement doesn't hold the value you think it does when the query is
submitted.

Hope this helps,
Ron

sungeiway wrote:
> 
> The below script work well when i execute it.
> But it won't work when i change the statement from
> $statement='select * from table';
> to   $statement='select * from table where (id='12345') and
> (email='email@stripped')';
> Does anybody know the reason??Please give me any suggestion to overcome
> it.Thanks.
> 
> #!c:\perl.exe
> use CGI ':standard';
> use DBI;
> # you may need to change these values
> $db_name =    'xxxx';
> $user =      'xxxx';
> $password =  'xxxx';
> $hostname = 'xxxx';
> print header();
> $dbh = DBI->connect("DBI:mysql:$db_name:$hostname", $user, $password);
> unless ($dbh) {
>      print "could not connect to database: $DBI::errstr\n";
>      exit 1;}
> $statement='select * from table';       ##############
>                  $sth =$dbh->prepare(
>                         $statement
>                         );
>                  if ( !defined $sth ) {
>                      die "Cannot prepare statement: $DBI::errstr\n";
>                    }
>                  $sth->execute;
>                  while ( @row = $sth->fetchrow() ) {
>                      print "Row returned: @row\n ";
>                    }
>                  $sth->execute;
>                  $sth->finish;
> $dbh->disconnect();
> print "It works.<br>\n";
> exit 0;
> 
> ____________________________________________________________________
> Get your own FREE, personal Netscape WebMail account today at
> http://webmail.netscape.com.
> 
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
> posting. To request this thread, e-mail mysql-thread10660@stripped
> 
> To unsubscribe, send a message to the address shown in the
> List-Unsubscribe header of this message. If you cannot see it,
> e-mail mysql-unsubscribe@stripped instead.
Thread
statement can't worksungeiway19 Aug
  • Re: statement can't workThimble Smith19 Aug
  • Re: statement can't workRonald Beck19 Aug