MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:sungeiway Date:August 19 1999 7:32am
Subject:statement can't work
View as plain text  
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
Does anybody know the reason??Please give me any suggestion to overcome

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( 
                 if ( !defined $sth ) {
                     die "Cannot prepare statement: $DBI::errstr\n";
                 while ( @row = $sth->fetchrow() ) {
                     print "Row returned: @row\n ";
print "It works.<br>\n";
exit 0;

Get your own FREE, personal Netscape WebMail account today at
statement can't worksungeiway19 Aug
  • Re: statement can't workThimble Smith19 Aug
  • Re: statement can't workRonald Beck19 Aug