Parse error declaring a variable in a function?

A

Anonymous

Guest
I keep getting a parse error when trying to declare a simple string variable from with a function (using PHP). I can do things like...

$db = mysql_connect("localhost", "user", "pass");

but if I try...

$this = "that";

I get a parse error on the line.
What's wrong? Please let me know if I'm not providing enough information. Thank you for you time and attention.
 
a little more info would help.
the only problem I see at the moment is the variable name.
'$this' is an object reference and as such shouldn't be attributed a value.
$this->varname = "value"; would be fine once the object has been instantiated.

what exactly are you trying to achieve?

on a different slant: if your function is not within a class, try globalizing the variable first

function blat()
{
global $fooey;
$fooey = "word";
}
 
Thank you for taking the time to respond. I'm sorry to report that the error was being cause due to a missing quotation mark 3 lines up. I must had looked at it at least 10 times, and never noticed it.
 
Back
Top