T_STRING error on line that just says <?php - php

So I'm writing a script in codeigniter, and I get the following error message:
Parse error: syntax error, unexpected T_STRING in /home/globalar/public_html/givinghusband.com/system/application/controllers/sizes.php on line 1
the only problem: the only thing on that line is this:
<?php
So I'm quite mysterified as to what's going on here? Have I typed PHP wrong or what?

There could be a problem with your editor when it updated the file. I just had this problem and the editor removed all line breaks.
If you are uncertain try opening your php file in another editor or use the Cpanel file manager to take a peak.

Or you may have an unterminated quote or statement on some previous line without an ending semicolon (;) . Check all files that are included before this one.

a bare <?php in the file leads to a parse error in php (don't ask). Try adding a whitespace or a newline after it

Sorry.A bit late but might helpful for others.Just looked at your question.Just use
<?
?>
instead of :
<?php
?>
and remove whitespaces/line breaks between your php open tag and class name .It will resolve this conflict.Ta

Related

Parse Error OptimizePress 2 WP

Parse error: syntax error, unexpected 'OptimizePress_Install'
(T_STRING) in
/home/investor/public_html/wp-content/themes/optimizepress/lib/admin/install.php
on line 1
Getting this annoying error when I click on "Activate Theme". How do I get around this? Code is below on pastebin
http://pastebin.com/GJkL64d1
First of all it needs a space between <?php and class so change it to <?php class
The second reason is it failing is because it is a 1 line script (all goes is on one line).
The first time it meets a comment the rest of the script is commented out.
You can fix this by
Download the file where is it not a strange one line.
Remove all comments
Beautify the php (make currect spaces)

Parse error: syntax error, unexpected T_LOGICAL_AND

I want to get variables defined in php.ini file and below is the line to do that.
$settings = parse_ini_file("php.ini");
It gives error
PHP Parse error: syntax error, unexpected T_LOGICAL_AND in path/of/file on line 218
That line in php.ini is
; <? and ?> tags as PHP source which should be processed as such. It's been
I think this is due to word and. But this line is a comment. So why is it giving this error?
Edit : Removing and from line in php.ini file solved issue. I don't know why it was causing problem. I changed line to
; <? n ?> tags as PHP source which should be processed as such. It's been
You made something wrong, I guess you included the file somewhere.
<?php tags in comments (or wherever) will not start a code section in an ini file meaning that parse_ini_file() will never start a PHP parser.
Steps to reproduce:
test.ini:
;<?php and ?>
a=1
test.php:
<?php
var_dump(parse_ini_file('test.ini'));
Output:
array(1) {
'a' =>
string(1) "1"
}
You see it works like a charm.
The error is not in php.ini, but somewhere about line 218 of your source file.
I dont see any comment lines
add // at the start of line or put that text in /* comment goes here*/
these brackets!

PHP error on a line of code I don't understand

I have an error on this code:
code:
$sessionsAry[] .= array('SessionId'=>$row['SessionId'], 'Mark'=>$row['Mark']);
error:
Parse error: syntax error, unexpected T_VARIABLE in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 122
What does this error mean and where is the error on this particular code?
First, remove the '.'
$sessionsAry[] = array('SessionId'=>$row['SessionId'], 'Mark'=>$row['Mark']);
Now, if you're still getting the error, make sure that $sessionsAry is an array and that $row is an array too. Try:
var_dump($sessionsAry, $row);
Also, make sure that you haven't missed off a ';' on the line before.
On line 121 you definetly forgot to put a semicolon, that is #1 explanation for this error usually.
You don't need to write .= since $array[] add a new entry to $array. So, use simply =.
When you see a "Parse error" spit out by PHP, it usually means you forgot a character (;) or formatted an expression incorrectly (.= has an extra period) . Consider getting a new PHP IDE that can point the error before you run the code. It will drastically help speed up your ability to code in PHP.

Issue with dynamically generated javascript link with PHP

example link
returns PHP error:
syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';'
Any ideas? (Hope this question makes sense. I'm trying to fix someone else's code.)
Check that there's not a "<?" or "<?php" at the beginning of the file. This code assumes you're not already within a PHP block. If you are, then you'll have to adjust (remove it). Or, you'll need to add close ?> somewhere before this html, and a <?php after it...
Sorry about that guys, the problem was <?php echo val;?> instead of <?php echo $val;?>. Sometimes the eyes betray the mind...

Parse error: syntax error, unexpected T_SL on line 23

I am getting this error:
Parse error: syntax error, unexpected
T_SL on line 23
Here is line 23:
$selectorder = <<<ORDER
Here it is in context:
$grid->setUrl('myfirstgrid.php');
$selectorder = <<<ORDER
function(rowid, selected)
{
if(rowid != null) {
alert("selected: "+rowid);
}
}
ORDER;
$grid->setGridEvent('onSelectRow', $selectorder);
What is causing this error?
I personally don't know what <<< does and have never used it, I got it from a tutorial. I tried to google it, but you can't google characters like that :(
Check for whitespace after <<<ORDER. There should be no blank characters.
<<< is for heredoc: See manual
Make sure that there is no SPACE/INDENTATION before ending ORDER;
PHP Heredoc does not get on well with the % symbol, and the following also causes Parse error: syntax error, unexpected T_SL:
<?php
$var=<<<%%SHRUBBERY%%
Nih!
%%SHRUBBERY%%;
?>
Also make sure that you have 3 '<<<'. Omitting one will throw this error. Also if your using NOWDOCs, make sure your hosting provider has php 5.3 installed. Plus if your php environment is below 5.3, do not use double quotes or single quotes.
It's called "Heredoc syntax", and it lets you specify large strings without using quotes. In this case, it looks like you're using it to put JavaScript code into a variable. Since you started the string with <<<ORDER, you should be able to finish it with ORDER;, as you have — but you need to make sure that ORDER; occurs at the start of a line, with no whitespace before it.

Categories