hello..
hai to all. i am fetching description which is in database. that description has 5 pharas. i am desplaying in front side and calling translation function. now i am getting this error.
Warning: file_get_contents(http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%26lt%3Bp%20class%3D%26quot%3Bnormal_text%26quot%3B%26gt%3BA%20woman%60s%20body%20performing%20to%20its%20utmost%20capability-%20that%60s%20what%20pregnancy%20is.%20From%20conception%20to%20delivery%2C%20the%20female%20form%20is%20tried%20and%20tested%20to%20carry%20and%20bring%20forth%20new%20life.%20The%20natural%20action%20can%20be%20quite%20exhausting%21%20If%20incorporating%20a%20pregnancy%20massage%2C%20the%20benefits%20to%20the%20expecting%20mother%20are%20incredible.%26lt%3B%2Fp%26gt%3B%3Cbr%20%2F%3E%0D%0A%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26lt%3Bp%20class%3D%26quot%3Bnormal_text%26quot%3B%26gt%3BPregnancy%20massage%20therapists%20specially%20trained%20in%20this%20area%20understand%20the%20exacting%20requirements%20of%20a%20mother%20to%20be.%20They%20are%20particularly%20skilled%20in%20the%20best%20pregnancy%20massage%20techniques.%20They%20understa in C:\wamp\www\addmultiplelanguajes-2009-08-15\k2.php on line 47
actually this is my script. plz remember one thing what it is means fetching value must and should have minimum 5 to 6 pharas. why becoze i am fetching the value which have only two pharas. that is displaying with out error. when i am displaying above 2pharas getting above error.
<?
ob_start();
extract($_REQUEST);
extract($_POST);
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db=mysql_select_db('flower',$con);
if (!isset($_GET['language']) || empty($_GET['language'])) {
$_GET['language']='en';
}
/**
* Translating language with Google API
* @author gabe@fijiwebdesign.com
* @version $id$
* @license - Share-Alike 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
*
* Google requires attribution for their Language API, please see: http://code.google.com/apis/ajaxlanguage/documentation/#Branding
*
*/
class Google_Translate_API {
/**
* Translate a piece of text with the Google Translate API
* @return String
* @param $text String
* @param $from String[optional] Original language of $text. An empty String will let google decide the language of origin
* @param $to String[optional] Language to translate $text to
*/
function translate($text, $from = '', $to = 'en') {
$url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='.rawurlencode($text).'&langpair='.rawurlencode($from.'|'.$to);
$response = file_get_contents(
$url,
null,
stream_context_create(
array(
'http'=>array(
'method'=>"GET",
'header'=>"Referer: http://".$_SERVER['HTTP_HOST']."/\r\n"
)
)
)
);
if (preg_match("/{\"translatedText\":\"([^\"]+)\"/i", $response, $matches)) {
return self::_unescapeUTF8EscapeSeq($matches[1]);
}
return false;
}
/**
* Convert UTF-8 Escape sequences in a string to UTF-8 Bytes
* @return UTF-8 String
* @param $str String
*/
function _unescapeUTF8EscapeSeq($str) {
return preg_replace_callback("/\\\u([0-9a-f]{4})/i", create_function('$matches', 'return html_entity_decode(\'&#x\'.$matches[1].\';\', ENT_NOQUOTES, \'UTF-8\');'), $str);
}
}
function display($input) {
$trans_text = Google_Translate_API::translate($input, '', $_GET['language']);
if ($trans_text !== false) {
echo $trans_text;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Untitled Document </title>
</head>
<body>
<form name="language" action="<?=$_SERVER['PHP_SELF']?>" method="GET">
<select onchange = "document.language.submit()" name="language">
<option selected="selected"><? display('select-language');?></option>
<option value="en"><? display('English')?></option>
<option value="es"><? display('Spanish')?></option>
<option value="fr"> <? display('French')?></option>
<option value="hi"> <? display('Hindi')?></option>
<option value="zh-CN"> <? display('chinese')?></option>
</select><br>
<? $select=mysql_query("select * from aboutus where auto_id=24");
$fetch=mysql_fetch_array($select);
echo display(stripslashes($fetch['about']));
?>
</form>
</body>
</html>