nettoon1991 Posted July 7, 2008 Share Posted July 7, 2008 This is that script i put together and i have no idea what im doing so i wonder if someone could help. <?php echo "<table cellpadding=3 cellspacing=3 border=0><tr><td>\n" ."<form action=\"".$PHP_SELF."\" method=\"post\">Nick:\n" ."<td><input type=\"text\" name=\"nick\" class=tagput>\n" ."</table><input type=\"submit\" name=\"tagit\" value=\"Submit\" class=tagput>\n" ."<input type=\"hidden\" name=\"action\" value=\"talk\">\n" ."</form><BR>"; if (isset($_POST['nick'])) { $nick = $_POST['nick']; echo'<script type="text/javascript">document.location.href=\'http://chat.dairc.net/chat.php?nick=$nick&channel=buzzms&client=java'</script\">'; } ?> This is the error i keep getting Parse error: syntax error, unexpected '/' in test.php on line 11 Link to comment https://forums.phpfreaks.com/topic/113543-dont-understand-why-it-doesnt-work/ Share on other sites More sharing options...
ratcateme Posted July 7, 2008 Share Posted July 7, 2008 you mixed up the ending of this line it needs to be: echo'<script type="text/javascript">document.location.href=\'http://chat.dairc.net/chat.php?nick=$nick&channel=buzzms&client=java\'</script>'; Link to comment https://forums.phpfreaks.com/topic/113543-dont-understand-why-it-doesnt-work/#findComment-583395 Share on other sites More sharing options...
nettoon1991 Posted July 7, 2008 Author Share Posted July 7, 2008 Thank you for fixing the error but i dont understand why the $nick isnt working :'( echo'<script type="text/javascript">document.location.href=\'http://chat.dairc.net/chat.php?nick=$nick&channel=buzzms&client=java\'</script>'; Link to comment https://forums.phpfreaks.com/topic/113543-dont-understand-why-it-doesnt-work/#findComment-583406 Share on other sites More sharing options...
wrathican Posted July 7, 2008 Share Posted July 7, 2008 you need to tell php to output the variable instead of the string. what your doing is telling php the echo $nick. that being the actualt bit that you typed. that you need to do is concetenate the string. like so echo 'blahh ' . $nick . ' blahh.'; Link to comment https://forums.phpfreaks.com/topic/113543-dont-understand-why-it-doesnt-work/#findComment-583410 Share on other sites More sharing options...
kenrbnsn Posted July 7, 2008 Share Posted July 7, 2008 Variables in strings delimited by single quotes do not get expanded. Use double quotes or concatenation: <?php echo "<script type='text/javascript'>document.location.href='http://chat.dairc.net/chat.php?nick=$nick&channel=buzzms&client=java'</script>"; ?> or <?php echo '<script type="text/javascript">document.location.href="http://chat.dairc.net/chat.php?nick=' . $nick . '&channel=buzzms&client=java"</script>'; ?> If you have no idea what you are doing, I suggest you start by learning basic syntax of PHP. Ken Link to comment https://forums.phpfreaks.com/topic/113543-dont-understand-why-it-doesnt-work/#findComment-583412 Share on other sites More sharing options...
nettoon1991 Posted July 7, 2008 Author Share Posted July 7, 2008 Thank you for telling me what i should do Link to comment https://forums.phpfreaks.com/topic/113543-dont-understand-why-it-doesnt-work/#findComment-583417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.