Please keep in mind I'm a pretty big newb when it comes to this... I'm trying to pass a keyword through the URL into text onto a page of my site. Page URL example: www.example.com/index.php?kw=example I'm using this to do so: <?php $keyword = $_GET[’kw’]; $keyword2 = $_GET[’kw’]; $keyword = ucwords(str_replace("+"," ",$_GET[’kw’])); $keyword2 = ucwords(str_replace("+","_",$_GET[’kw’])); ?> Code (markup): Then to call it in the page, I'm using: <?php echo $keyword; ?> <?php echo $keyword2; ?> Code (markup): But my echo's refuse to show anything (just blank) instead of showing the word 'example' like they should from the URL above. I'm not getting any syntax errors, just nothing is displaying. Anyone able to tell me where I'm messing up? Thanks!
I tried your exact code and got the following errors: Notice: Use of undefined constant ’kw’ - assumed '’kw’' in [xxx]\get-test.php on line 4 Notice: Undefined index: ’kw’ in [xxx]\get-test.php on line 4 Notice: Use of undefined constant ’kw’ - assumed '’kw’' in [xxx]\get-test.php on line 5 Notice: Undefined index: ’kw’ in [xxx]\get-test.php on line 5 PHP: Changing the quotes will make it work.
Echo the $_GET variable to see what things are exists in it. You may get an idea why it is not working. echo "<pre>"; print_r($_GET); echo "</pre>"; Code (markup):