Can't get .php to output to the browser - php

I am completely new to coding and my current assignment is just to use a "here document" block. All the code I have for the program is:
<?php
$firstphpstring = <<<ONTOTHENEXTONE
I have now coded my first block to be displayed
in my very first web page.I am excited to see what the
next several weeks have in stored.
ONTOTHENEXTONE;
echo $firstphpstring;
?>
But I keep getting the following error:
Parse error: syntax error, unexpected T_SL in > C:\wamp\www\php_foothill\Week2Lab_CIS052N_heredoc_gettype.php on line 2
I am using Windows 7, WAMPServer 2.2, and have the .php file in a folder in C:\wamp\www

Remove the space after the <<<ONTOTHENEXTONE.

Related

For loop does not work with Wordpress plugin

I'm using this plugin in Wordpress to write php in a page but every time I use a for loop it gives me this error:
Parse error: syntax error, unexpected end of file, expecting ';'
How do I solve this?
This plugin does not work with loops. It is a known issue if you take a look at the reviews.
There is a plugin that I often use and that works perfectly. It is called WP-exec PHP.
Link here: https://wordpress.org/plugins/wp-exec-php/

Laravel - syntax error, unexpected end of file

I have a website which works fine on host, but I'm currently trying to install it on localhost.
I've downloaded everything and configured to work on localhost - Database & URL.
The problem is this error:
Unhandled Exception
Message:
syntax error, unexpected end of file Location:
C:\Program Files (x86)\EasyPHP-12.1\www\laravel\view.php(386) :
eval()'d code on line 118
And I don't know what causes it. Any solutions?
P.S. I've setup in my windows' host file 127.0.0.1 myproject.dev.
There is an error within one of your views. If there is a more detailed stack trace it should show you details of a view, although the name will be an md5() string so it's a bit hard to find. You might want to delete all compiled Blade views in storage/views and let Blade re-compile the views.
If you still get the error then check your views to make sure you have all the proper closing tags, e.g., #endif or #endforeach
Always double check your views for any syntax errors.
I've run into this same error and I was able to fix it by adding spaces to the content within an inline if statement. For example:
Experienced error with:
#if( BLAH )Output#endif
Fixed error with:
#if( BLAH ) Output #endif
This may not be a problem in all cases and it was certainly difficult to track down but it is just one example that can cause this exact error.
A variation of this problem -- I had a php block, which I'd opened with
<? as opposed to <?php worked fine on LocalHost/MAMP, but gave the above error under Nginx/Ubuntu 16.04/PHP7 (both Laravel)
you should remove a character from view file. for example my character was "," (a comma) before some "#endfor". when i remove those worked!

code for a PHP form that connects with a database

I am having problems with creating a PHP form for a web site that popluates a MySQL database.
Here is the error message I am getting at the following URL: http://www.laboro.biz/employer.php:
Parse error: syntax error, unexpected $end in /hermes/bosoraweb013/b1108/ywh.tsarge83/laboro/employer-FormToEmail.php on line 228
The other file that is the action file is http://www.laboro.biz/employer-FormToEmail.php.
I need help with scripting to make this work.
Can anyone please help?
You're missing a curly brace somewhere in your script.
You're missing a { or have one more } or ; than needed. Look it over.

wordpress (301 redirect plugin)/ php question

I am setting up a website in wordpress. the site was done by someone else. After setting up the site / database I get the following error:
Parse error: syntax error, unexpected $end in C:\Documents and Settings\user101\
Desktop\wordpress\wp-content\plugins\wp-301redirect\wp-301redirect.php on
line 320
line 320 is the very last line of wp-301redirect.php page. I looked up what 301redirect is and it is apparently a plugin. The wp-301redirect.php page I have is exactly what the plugin provides (zip download). line by line.
Does anyone know what might be causing this.?
In the default file for this plugin. line 220 has <? it should be changed to <?php to fix this error
Try removing the last line after ?>. And generally it's advisable to not close your PHP with ?> as it's not required and prevents this from happening in the first place.
Most likely, a function or control block is missing its matching end-brace, such as:
function foo() {
//stuff
...
// EOF
OR
if (true) {
...
// EOF

Unbelievable PHP script won't echo out string

I have a test.php script which contains this:
<?php echo 'test'; ?>
When I point to it via my browser, it works and prints out "test" as expected.
I have another script which I am trying to test but however, it is ignoring all my echos! I thought I would put an echo right at the top as this will surely work, but when I get to this script via POST request from a form. It does not even echo out what is at the top of the line:
<?php echo 'START START START';
error_reporting(E_ALL);
I even point to from my browser and still no output?
What the hell is going on?
Update
The error log shows this :
PHP Parse error: syntax error, unexpected T_ECHO in /var/www/tester/convertor.php
But the echo is at the top of the line. I am going to set diaplay errors.
You have a parse error, so the script isn't even executed. So it's expected that it won't output anything.
The parse error can be for any echo in the script. It may be because of an "echo" statement after a line missing a semicolon, for example.
Things to try:
Check your error log
Check the headers (is it coming back 404?)
Make sure you view-source: don't just look in the browser
Delete everything except the echo. If it works, add things back a bit at a time until it breaks.
Load your script in a hex editor and make sure there aren't any weird characters in there
Are you including this file from another file? If so, check the other file too. Watch out for output buffering.
Put exit; after the echo start start start and see if that works. Look in the apache error log for clues. Comment out the rest of the PHP code in the file and see if it works then...
UPDATE
I have had this when copy pasting white space from a browser sometimes - e.g. copy/pasting some code from a web page. Sometimes weird control characters get embedded invisibly in the white space, and I find that deleting the whitespace and re-entering it fixes it. Did you copy paste anything into this file?
Are you hosting this page on a server with PHP installed?
If you just have a .php file on your hard drive somewhere and open it in a web browser, it won't work. You need to be running a web server with PHP extensions and access the file using the HTTP or HTTPS protocols.
On a similar note to this i have seen alot of scripts throw errors like this when they have come from developers on windows (i'm on linux).
I have to go to the start of the php file and hit delete a couple of times to get rid of some invisible characters before the script will run.
You're missing the ending ?>
<?php
echo 'START START START';
error_reporting(E_ALL);
?>

Categories