discussnow Posted October 29, 2008 Share Posted October 29, 2008 Hello all, I am new to programming and currently teaching myself php. I know this error usually occurs if your missing a bracket or semicolon but I can't seem to see it. <? php $para = $_POST('send'); $result = explode('.',$para); echo $result ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/ Share on other sites More sharing options...
Caesar Posted October 29, 2008 Share Posted October 29, 2008 <?php $para = $_POST['send']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677612 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 Still seeing an error. Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677616 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 Did you change () to [] ? Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677623 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 Did you change () to [] ? <? php $para = $_POST['send']; $result = explode('.',$para); echo $result ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677628 Share on other sites More sharing options...
Maq Posted October 29, 2008 Share Posted October 29, 2008 If you want to print the contents of an array you should use print_r($result); Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677631 Share on other sites More sharing options...
prexep Posted October 29, 2008 Share Posted October 29, 2008 And a side note. Line 4 should be like echo $result; NOT echo $result ; Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677638 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 @Maq: But that wouldn't give the Unexpected T_VARIABLE warning, would it? @prexep: PHP ignores whitespace, so you can have half a dozen spaces, tabs and linebreaks before ; and still have working script. Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677641 Share on other sites More sharing options...
prexep Posted October 29, 2008 Share Posted October 29, 2008 @Maq: But that wouldn't give the Unexpected T_VARIABLE warning, would it? @prexep: PHP ignores whitespace, so you can have half a dozen spaces, tabs and linebreaks before ; and still have working script. It was a guess. Never tested it Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677646 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 Well I just did... just in case documentation was wrong Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677649 Share on other sites More sharing options...
Maq Posted October 29, 2008 Share Posted October 29, 2008 @Maq: But that wouldn't give the Unexpected T_VARIABLE warning, would it? Never said it did but you're right, it wouldn't resolve the Unexpected T_VARIABLE warning. I was just telling him how to properly display the contents of an array. Anyway, your syntax is correct now, I don't know what is causing this. Does the error specify a line number? Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677652 Share on other sites More sharing options...
wildteen88 Posted October 29, 2008 Share Posted October 29, 2008 Can you post the error message you're receiving here in full. Also the first line of your script should be <?php not <? php Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677654 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 Parse error: syntax error, unexpected T_VARIABLE in /home/newsexst/public_html/Hello.php on line 13 13 is the first line after <?php Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677678 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 What's before <?php ? Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677683 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 What's before <?php ? html Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677686 Share on other sites More sharing options...
Maq Posted October 29, 2008 Share Posted October 29, 2008 What's before <?php ? html Lol, usually is, post the code!!! Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677690 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 No other php before it? Is this file included into some other script? Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677691 Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 i think i have it. use this: <?php if (isset($_POST['send'])){ $para = $_POST['send']; $result = explode('.',$para); echo $result ; } Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677695 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 Nope. THe previous code would only produce a Notice if $_POST['send'] was not set. I run the code here, and it works without throwing a Warning. It's probably something before line 13. Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677699 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 What's before <?php ? html Lol, usually is, post the code!!! Haha realized the stupidity of what I said <html> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <title> Paragraph Scrambler </title> <body> Paste Paragraph <br> <textarea name="para" type="text" row="5" col="5"><br> <input name="send" type="submit" value="Submit!"> <input type="reset" value="Cancel"> </body> <? php $para = $_POST['send']; $result = explode('.',$para); echo $result ; ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677726 Share on other sites More sharing options...
kenrbnsn Posted October 29, 2008 Share Posted October 29, 2008 This: <? php needs to be <?php i.e. no space between the "?" and "php". Ken Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677727 Share on other sites More sharing options...
Mchl Posted October 29, 2008 Share Posted October 29, 2008 That should be it. Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677731 Share on other sites More sharing options...
bobbinsbro Posted October 29, 2008 Share Posted October 29, 2008 try closing your textarea... (<textarea name="para" type="text" row="5" col="5"></textarea>) Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677734 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 This: <? php needs to be <?php i.e. no space between the "?" and "php". Ken Thanks! I had it originally like that and had another error so I didn't notice that the space was also producing one! Really Appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677736 Share on other sites More sharing options...
discussnow Posted October 29, 2008 Author Share Posted October 29, 2008 try closing your textarea... (<textarea name="para" type="text" row="5" col="5"></textarea>) That didn't cause the error, but it did put html in the box! thanks! Quote Link to comment https://forums.phpfreaks.com/topic/130610-unexpected-t_variable-error/#findComment-677737 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.