hI2all.I have found working script of google suggest script! but in
php... could you give me working in perl?
or maybe found error in my?
php
--
<?php
$db = new mysqli('localhost', 'root' ,'', 'countries');
if(!$db) {
echo 'ERROR: Could not connect to the database.';
} else {
if(isset($_POST['queryString'])) {
$queryString =
$db->real_escape_string($_POST['queryString'])
if(strlen($queryString) >0) {
$query = $db->query("SELECT value FROM countries WHERE value LIKE
'$queryString%' LIMIT 10");
if($query) {
while ($result = $query
->fetch_object()) {
echo '<li
onClick="fill(\''.$result->value.'\');">'.
$result->value.'</li>';
}
} else {
echo 'ERROR: There was a problem with
the query.';
}
} else {
// Dont do anything.
} // There is a queryString.
} else {
echo 'There should be no direct access to this script!';
}
}
?>
--
---
$dbh = DBI->connect("dbi:ODBC:FRBD", "user", "pass",
{RaiseError => 1}) or die "$DBI::errstr";
if($ENV{'REQUEST_METHOD'} eq 'GET'){$query=$ENV{'QUERY_STRING'};
}
elsif($ENV{'REQUEST_METHOD'} eq 'POST'){sysread STDIN,$query,
$ENV{'CONTENT_LENGTH'};
}
@formfields=split /&/,$query;
foreach(@formfields){
if(/^queryString=(.*)/){$queryString=urldecode($1);}
}
if ($queryString) {
my $sql = qq{ SELECT ATS, Name, Port FROM [TML] WHERE
Name='$queryString' };
my $sth = $dbh->prepare( $sql );
$sth->execute();
my( $ats, $name, $port );
$sth->bind_columns( \$ats, \$name, \$port );
while( $sth->fetch() ) {
print "$name | $ats | $port\n";
#print '<li onClick="fill(\''.$name.'\');">'.$name.'</li>';
}
}
sub urldecode{
local($val)[EMAIL PROTECTED];
$val=~s/\+/ /g;
$val=~s/%([0-9A-H]{2})/pack('C',hex($1))/ge;
return $val;
}
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/