Jump to content

Dont understand why it doesnt work


nettoon1991

Recommended Posts

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

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.';

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.