View Full Version : Whats going on?
Jermaine
08-04-2007, 01:45 AM
What is wrong with this code? Everytime I upload it I get a
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in ..........on line............
It says that it the line with a variable on it.
No matter what variable it is I get the message.
<?php
echo "Trying to learn php!";
echo '<br />';
$myvar = "This is a variable";
$ANUMBERVAR = 19;
?>
can someone tell me whats wrong?
dougp
08-04-2007, 02:38 AM
Do not see any problems, works fine for me. If there is more than just that code you have there in the file, make sure any other code is properly terminated or remove it and test the original code by itself as it works fine. If not, then server glitch or? Are you testing on Cirtex Servers or one of your own on your own machine? (such as downloaded Apache)
Also try this, if you need help understanding something let me know.
<?php
// Begin Old Code Commented Out
/*
echo "Trying to learn PHP!";
echo "<br />";
$myvar = "This is a variable";
$numvar = 19;
*/
// End Old Code Commented Out
// Begin New Code
function breakmyline($passedvar) {
if ($passedvar == '') {
$setvar = "<br />\n";
return $setvar;
} else {
?>
<br />
<?
}
}
$varfunc = breakmyline("");
$numvar = 19;
$numbermath = $numvar + 1;
$var = "Trying to learn PHP! ". $varfunc ."You will get the hang of it... Looks fine here.\n";
echo "$var\n";
breakmyline("nope_not_null");
echo "My Number: $numvar $varfunc\n";
echo "Lets add one: $numbermath\n";
// End New Code
?>
It outputs:
Trying to learn PHP!
You will get the hang of it... Looks fine here.
My Number: 19
Lets add one: 20
I my code above, I am showing you that you don't have to echo html. You can use PHP only where needed in your origional code. Or using a function, you can do both where needed ;)
Another example:
<?php
// Make sure to include the function from first code to make this work...
$mycolorcode = "#ffffff";
$content = "Somedata here, on body of page". $varfunc ."\n";
$content .= "We can fill more data into the var using the .=\n";
?>
<html>
<head>
<title></title>
</head>
<body bgcolor="<? echo "$mycolorcode"; ?>">
<? echo "$content"; ?>
</body>
</html>
"Source code" for above would output like this:
<html>
<head>
<title></title>
</head>
<body bgcolor="#ffffff">
Somedata here, on body of page<br />
We can fill more data into the var using the .=
</body>
</html>
// Regards,
Doug
Jermaine
08-04-2007, 01:26 PM
thanks for the help. I been trying this on cirtex servers. Maybe it is a glitch?
But thanks I'm trying your code now.
dougp
08-05-2007, 08:27 AM
Could be a glitch.
I am on server Curry, and the above codes work fine you can see it all the above examples together here:
http://examples.pierats.us/examples.php
http://examples.pierats.us/examples.php5
Jermaine
08-05-2007, 10:06 PM
yeah i fixed it.
thanks
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.