in reply to Call Perl script from Javascript
<?php $username = "root"; $password = "root"; $hostname = "127.0.0.1:3306"; $dbname = "AI"; $word = $_GET['word']; $sql = "SELECT crps_word, crps_probability FROM arabic_cor +pus WHERE crps_word like '$word%' ORDER BY crps_probability LIMIT 10 +"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); // Set Encoding Set to utf8 mysql_query("SET character_set_results=utf8", $dbhandle); mb_language('uni'); mb_internal_encoding('UTF-8'); mysql_select_db($argDB, $dbhandle); mysql_query("set names 'utf8'",$dbhandle); //select a database to work with $selected = mysql_select_db($dbname,$dbhandle) or die("Error selecting database"); //execute the SQL query and return records $result = mysql_query($sql, $dbhandle); if($result) { //fetch tha data from the database while ($row = mysql_fetch_array($result)) { $word = $row{'crps_word'}; $prob = $row{'crps_probability'}; $str = $prob."----".$word; echo "<option value = '$word'></option>"; } } //close the connection mysql_close($dbhandle); ?>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Call Perl script from Javascript
by tangent (Parson) on Mar 19, 2014 at 22:55 UTC |