mysql - How to pass multi word string as a variable used in url in php -


i making voice dictionary. here code.its working fine no errors slight problem. line towards end have problem.

http://tts-api.com/tts.mp3?q=$z";?>" type="audio/mp3" />

$x , $y variables contain single word ..so converted speech without need of encoding , code works fine them. when write $y stores meaning , speech output not there meaning contains multi word string has encoded first ( dont know how encode it).

plz tell me changes have in order convert meaning part text speech.

i tried http://tts-api.com/tts.mp3?q=.urencode($y)"; ?>" type="audio/mp3" />

but didnt work. plz help

<html> <head> <title>word meanings</title> <?php mysql_connect("localhost", "root", "radhika"); mysql_select_db("dictionary"); if(isset($_post['submit1'])) {   $req=$_request['word'];  $strsql = "select * dict word='$req'";  $rs = mysql_query($strsql);  while($row = mysql_fetch_array($rs))  {         $x=$row["word"];     $y=$row["meaning"];     $z=$row["synonym"];     echo "<b>word</b>: " . $x ."<br/>" ;     echo "<b>meaning</b>: " . $y ."<br/>" ;     echo "<b>synonym</b>: " . $z ."<br/>" ;   }  }  mysql_close();  ?>  </head> <body> <form name="form1" action="lastry.php" method="post"> <input type="text" name="word" value="<?php echo isset($_post['word'])?$_post['word']:''?>"x-webkit-speech/> <input type ="submit" name ="submit1" value ="submit">  </form> <?php  if($_post) { ?>  <audio controls="controls" autoplay="autoplay"> <source src="<?php echo "http://tts-api.com/tts.mp3?q=$z";?>" type="audio/mp3" /> </audio> <?php }?> </body> </html> 

i'd suggest trying urlencode function , let know results:

e.g.

urlencode($z) 

in place of variables potentially have spaces / special characters within them.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -