phpRob Posted October 26, 2011 Share Posted October 26, 2011 Hi, Firstly I'd like to say 'm really enjoying the book, it expalins things a little slower than the php & mysql book which suits me better My question is regarding the chapter 3 pursue and the $_GET variable. "If you're the inquisiive type, and don't mind waiting for answers, try passing more complicated values to a page through the URL. Try using spaces and punctuation to see what happens." Earlier in the chapter you said "They won't be passed to the php script properly...", yet when I tried this it returned the value no problem? <div> <p>Click a name</p> <ul> <li><a href="hello.php?name=Paul 'John' Thomas">Paul 'John' Thomas</a></li> <li><a href="hello.php?name=Lee">Lee</a></li> <li><a href="hello.php?name=John">John</a></li> </ul> </div> Am I misunderstanding something here? I'm running PHP version 5.2.14. Thanks, Rob Link to comment Share on other sites More sharing options...
Larry Posted October 26, 2011 Share Posted October 26, 2011 I'm glad you're liking the book. As for your question, what happens when you click that first link? Link to comment Share on other sites More sharing options...
phpRob Posted October 26, 2011 Author Share Posted October 26, 2011 I get the message 'The name you selected was Paul 'John' Thomas' as expected even though it includes spaces and apostrophes. $name = $_GET['name']; print = "The name you selected was $name"; Link to comment Share on other sites More sharing options...
Larry Posted October 26, 2011 Share Posted October 26, 2011 Hmmm...that surprises me. What browser are you testing this in and have you tried other browsers? In the past, I've seen the spaces cause problems. Link to comment Share on other sites More sharing options...
phpRob Posted October 26, 2011 Author Share Posted October 26, 2011 Internet Explorer 9 and Firefox 7.0.1 both return correct values, not tried it on older browsers. Link to comment Share on other sites More sharing options...
Larry Posted October 27, 2011 Share Posted October 27, 2011 Okay, then. So maybe that's not causing a problem any more and kudos for discovering it. In real-world code, though, I'd always run values through urlencode() to make them safe to use in a URL. You'll learn about this function in time. 1 Link to comment Share on other sites More sharing options...
Recommended Posts