Reputation: 29
Quick question... I'm using this code to communicate with my flash application:
<?php
// Only run this script if the sendRequest is from our flash application
if ($_POST['sendRequest'] == "parse") {
// Print the var to flash
print "var1=The user's name is Harry";
}
?>
Now this works fine but as soon as I add a variable:
<?php
// Only run this script if the sendRequest is from our flash application
if ($_POST['sendRequest'] == "parse") {
$uname = "Name"
// Print the var to flash
print "var1=The user's name is Harry";
}
?>
I get an error stating:
Parse error: syntax error, unexpected T_PRINT in /home/a4935911/public_html/usersOnline.php on line 7
Where line 7 is my print statement. Why is this happening??? Please can someone help. PHP is driving me crazy...
Upvotes: 0
Views: 58
Reputation: 91759
PHP requires that you end lines with a semicolon unless it is the last line. This is because if the semicolon is omitted, it will be evaluated as the same expression as the next line. Change this:
$uname = "Name"
To this:
$uname = "Name";
Upvotes: 1
Reputation: 74220
Missing semi-colon in $uname = "Name"
change it to $uname = "Name";
Rewrite:
<?php
// Only run this script if the sendRequest is from our flash application
if ($_POST['sendRequest'] == "parse") {
$uname = "Name";
// Print the var to flash
print "var1=The user's name is Harry";
}
?>
Added note: A semi-colon can be omitted if it's the last line of code with nothing else that will be executed/included thereafter.
Upvotes: 2
Reputation: 3348
You need to end each statement with a semicolon ;
This error most often means you forgot one of these
' ; ' " ) ( [ ]
Change
$uname = "Name"
with
$uname = "Name";
Upvotes: 0