PHP T_STRING Error in Header Location - php

I keep getting this error..
PHP Parse error: syntax error, unexpected T_STRING in C:\inetpub\storeboard.com\oauth\callback.php on line 39
What am I doing wrong with this line of code? This is line 39
header('Location: ./save_twitter_tokens.php?nToken='.$access_token["oauth_token"].'&nSecret='.$access_token["oauth_token_secret"].');

maybe this will work:
header('Location: ./save_twitter_tokens.php?nToken='.$access_token["oauth_token"].'&nSecret='.$access_token["oauth_token_secret"]);

You can see it in the syntax highlighting of the code you posted. The last string doesn't get closed. Remove the .' at the end.

Related

Getting many syntax errors in my PHP code [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
This is my code. I am getting errors every time the page loads and I don't know what is wrong. If you could help me it would be greatly appreciated.
<?php
include ('steamauth/userInfo.php');
$myfile = fopen("userid.txt", "a+") or die("Unable to open file!");
if( strpos(file_get_contents("/userid.txt"),$_GET[$steamprofile['steamid']]) !== false){
fwrite($myfile,$steamprofile['steamid']);}
fclose($myfile)
else( strpos(file_get_contents("/userid.txt"),$_GET[$steamprofile['steamid']]) !== true){
fclose($myfile)
echo"<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=http://example.com">
<script type="text/javascript">
window.location.href = "http://example.com"
</script>
<title>Page Redirection</title>
</head>
<body>
<p>If you are not redirected automatically, follow the link to www.example.com</p>
</body>
</html>";}
?>
Here are the errors:
[25-Apr-2015 09:46:38 Australia/Perth] PHP Parse error: syntax error, unexpected '.', expecting ']' in /example.com/userid.php on line 4
[25-Apr-2015 09:47:42 Australia/Perth] PHP Parse error: syntax error, unexpected '.', expecting ']' in /example.com/userid.php on line 4
[25-Apr-2015 09:48:09 Australia/Perth] PHP Parse error: syntax error, unexpected '.', expecting ']' in /example.com/userid.php on line 4
[25-Apr-2015 09:48:40 Australia/Perth] PHP Parse error: syntax error, unexpected '}' in /example.com/userid.php on line 7
[25-Apr-2015 09:49:37 Australia/Perth] PHP Parse error: syntax error, unexpected '}' in /example.com/userid.php on line 7
[25-Apr-2015 09:50:17 Australia/Perth] PHP Parse error: syntax error, unexpected T_ELSEIF in /example.com/userid.php on line 7
[25-Apr-2015 09:51:06 Australia/Perth] PHP Parse error: syntax error, unexpected T_ELSEIF in /example.com/userid.php on line 7
[25-Apr-2015 09:53:07 Australia/Perth] PHP Parse error: syntax error, unexpected '}' in /example.com/userid.php on line 6
[25-Apr-2015 09:55:06 Australia/Perth] PHP Parse error: syntax error, unexpected '.' in /example.com/userid.php on line 6
[25-Apr-2015 09:55:34 Australia/Perth] PHP Parse error: syntax error, unexpected '}' in /example.com/userid.php on line 6
[25-Apr-2015 09:56:53 Australia/Perth] PHP Parse error: syntax error, unexpected ')' in /example.com/userid.php on line 7
[25-Apr-2015 09:57:15 Australia/Perth] PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /example.com/userid.php on line 8
[25-Apr-2015 09:58:19 Australia/Perth] PHP Parse error: syntax error, unexpected T_ELSE in /example.com/userid.php on line 8
[25-Apr-2015 09:59:23 Australia/Perth] PHP Parse error: syntax error, unexpected T_ELSE in /example.com/userid.php on line 8
[25-Apr-2015 10:00:02 Australia/Perth] PHP Parse error: syntax error, unexpected T_ELSE in /example.com/userid.php on line 8
There are more (10 MB error log more), but these are the most recent and every time I change some new errors appear.
The code is supposed to open a file (userid.txt) then check if that file contains their steamid if it doesn't it writes in it, if it does then it redirects away.
If you have no idea, then at least Google search the type and name of the error - the error log does give you plenty enough information to solve your error. +1 for using the error log, -1 for not actually reading and using the information it gives you.
To give some more detail: the core of your errors is that you're not writing the PHP correctly, so this implies you don't know PHP, so really what you should be doing is not running before you can crawl and going away and reading up all about PHP and the structure and layout and methods behind the language and how to get intended results from the code you write.
Pretty much all your errors are down to bad syntax, I could rewrite the whole code block for you and format it correctly but really I think it's better for you to go away and read about how to structure IF statements, how to use strpos and how to open and edit files as starting points.
Also read up about how to structure arrays and google search info on how to structure Multidimensional arrays (as that's another syntax fault in your code).
And seriously, I do mean well done for using the error log. Many programmers in PHP merrily get things mostly working and completely ignore learning how to detect and collect their non-critical errors.
Some further pointers to this specific code:
check each instruction ends with a ;
check the difference between $_GET and $_POST, read about them in php.net, also read about what these identifiers actually are (they're special).
be careful with print and echo statements that the character they open with (" or ') is escaped (ie preceded by a backslash) if found inside the string.
check that multidimensional arrays are structured correctly - $array[0][1] NOT $array[0[1]]
check the URL to the files you want to use is correct.
Eat 5 different pieces of fruit or veg a day

unexpected T_STRING on first line of code

I have been getting an error saying unexpected T_STRING on line 2 of this script:
<? php
session_start();
$incidentKey = $_SESSION['incidentKey'];
$incidentDetailsQuery = mysql_query("SELECT * FROM incidents WHERE incidentKey='".$incidentKey."'");
while ($incidentDetails = mysql_fetch_assoc($incidentDetailsQuery);
?>
And despite looking through the forum heaps, I have had no luck. This was even coming up as an error saying unexpected T_STRING on line 2 when I the code started like this:
<? php
$incidentKey = $_SESSION['incidentKey'];
etc.....
I've gone through all other includes and couldn't find any missing terminators leading up to this script. Can anyone think why else I would be getting this error?
Remove the space in
<? php
to make it
<?php

PHP Parse error: syntax error, unexpected T_STRING

I'm working in OsCommerece and getting this up in my error log
PHP Parse error: syntax error, unexpected T_STRING in public_html/includes/classes/seo.class.php(2206) : eval()'d code on line 1
Maybe just remove the <?php, ?> tags, as seo.class.php seems to run the input through eval()
mixed eval(string $code)
The code mustn't be wrapped in opening and closing PHP
tags...

IPBoard Error Parse error: syntax error, unexpected T_STRING

I have been having this error with IPBoard when trying to install a skin/theme. I get this message when I apply it to my forum:
Parse error: syntax error, unexpected T_STRING in /home/a7952789/public_html/forum/cache/skin_cache/cacheid_7/skin_global.php on line 83
So I decided to check It out I re-parsed it and it said no errors in CODE. here is the exact line of code:
$this->functionData['globalTemplate'][$count_3b65c7bc63b10c5a7f84294eb9b75dd2]['array_header_items'] = $array header_items;
$array header_items doesn't make any sense. It might be a typo for $array_header_items, although it's hard to guess what it is supposed to be.

Parse error: syntax error, unexpected '(', expecting T_STRING in --------------/admin.php on line 26

i uploaded file but it show error.
Parse error: syntax error, unexpected '(', expecting T_STRING in ///admin.php on line 26
how can fix this error?
line is
function index($success){
include("header.php");
global $link,$prefix;
if (isset($success)) {
openTable();
echo "<center><font color='#FF0000'>$success</font><center><br>";
closeTable();
echo"<br>";
goto("index.php?file=admin");/ error line
}
Most probably you're using PHP 5.3, where goto is an operator and in that line you're calling a custom function goto(), which you've defined.
Solution: rename your function, something like go_to() will help.
Please refer PHP manual for goto here: http://php.net/manual/en/control-structures.goto.php
goto is used to shift execution to a different point in the same code file and you need to specify an identifier for another location in your code in the same file (refer to the example given in the PHP manual link). If you want to go to another link, use header() method instead.
header("Location:index.php?file=admin");
Manual here: http://php.net/manual/en/function.header.php
I've never used goto, but I just looked it up in the manual and they never used brackets around the destination. However if you want to redirect to another page, I think you're using the wrong method.

Categories