alexville Posted March 15, 2007 Share Posted March 15, 2007 I'm not sure if this is possible, but is there a way were you can take all the " out of a variable and replace it with ' ? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 15, 2007 Share Posted March 15, 2007 Use the str_replace function. <?php $str = 'this string has double quotes " " " in it'; $str = str_replace('"',"'",$str); echo $str; ?> If you explain why you want to do this, perhaps there is another solution to your problem. Ken Quote Link to comment Share on other sites More sharing options...
alexville Posted March 15, 2007 Author Share Posted March 15, 2007 I want people to be able to input data into my website say, maybe from YouTube. Here is the data: <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/ECM9N7jrA0o"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ECM9N7jrA0o" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> I have to make this code work in PHP, not HTML. Quote Link to comment Share on other sites More sharing options...
papaface Posted March 15, 2007 Share Posted March 15, 2007 What do you mean "make this code work in PHP" ? Quote Link to comment Share on other sites More sharing options...
alexville Posted March 15, 2007 Author Share Posted March 15, 2007 If I did this code: <? echo "<p><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/ECM9N7jrA0o"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ECM9N7jrA0o" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>"; ?> It wouldn't work because of the quotes. Quote Link to comment Share on other sites More sharing options...
Lumio Posted March 15, 2007 Share Posted March 15, 2007 <? echo '<p><object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/ECM9N7jrA0o"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ECM9N7jrA0o" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>'; ?> or <? echo "<p><object width=\"425\" height=\"350\">...</object>'; ?> Quote Link to comment Share on other sites More sharing options...
alexville Posted March 16, 2007 Author Share Posted March 16, 2007 I can't get it to work with a variable. This is my code: <? $text = $_POST['text']; echo '$text'; ?> The user inputs this : <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/ECM9N7jrA0o"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ECM9N7jrA0o" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> And this is what comes out of it: $text Quote Link to comment Share on other sites More sharing options...
effigy Posted March 16, 2007 Share Posted March 16, 2007 Please review strings. Not only are the quotes unnecessary, but single quotes do not interpolate variables. Quote Link to comment Share on other sites More sharing options...
virtuexru Posted March 16, 2007 Share Posted March 16, 2007 You need to slash them out... For example Say you want to output: <a href="blabla.com">here</a> You would need to do this.. echo "<a href=\"blabla.com\">here</a>"; Quote Link to comment Share on other sites More sharing options...
alexville Posted March 16, 2007 Author Share Posted March 16, 2007 Is their a script or a function that will do that when someone inputs data into a form and posts it to php? Quote Link to comment Share on other sites More sharing options...
fert Posted March 16, 2007 Share Posted March 16, 2007 http://us3.php.net/manual/en/function.addslashes.php Quote Link to comment Share on other sites More sharing options...
alexville Posted March 17, 2007 Author Share Posted March 17, 2007 I still can't get it to work. Can someone help me fix this code, so that the video will show? -- TEST1.PHP <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <form name="form1" method="post" action="test2.php"> <p> <input name="text" type="text" id="text"> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </body> </html> --- text2.php <? /* Include Files *********************/ session_start(); include("database.php"); include("login.php"); /*************************************/ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <? $text = $_POST['text']; echo addslashes($text); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.