PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to update the variable values in a vars.php document by completely rewriting it. Everything seems ok, but I get an error when I submit the form and execute the update.php. Error code is:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/myname/public_html/sys/update.php on line 6
I'm sure there is a problem somewhere that you could just space out the code to clean up but I wrote something a bit more advanced but will work for you.
Because you are using double-quotes, it thinks you are trying to put the $_POST variable inside the string. To fix it, just flip it, so the string is surrounded by single-quotes ( ' ), and you use double-quotes ( " ) on the key of the post var.
There's a couple potential problems there. First, as they're in double-quotes, all your variables will be evaluated. So, the file won't contain the string: '$duration1=$_POST['dura1']'
It will contain (assuming $duration1 = 'foo' and $_POST['dura1'] = 'bar') 'foo=bar'
I'm not sure if that was your intent or not.
Your parse error is coming from the fact that you've surrounded your $_POST keys in single quotes. Either remove the single quotes, or jump in & out of quotes (preferable in my opinion).
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
There's a couple potential problems there. First, as they're in double-quotes, all your variables will be evaluated. So, the file won't contain the string:
'$duration1=$_POST['dura1']'
It will contain (assuming $duration1 = 'foo' and $_POST['dura1'] = 'bar')
'foo=bar'
I'm not sure if that was your intent or not.
Yeah I've run into this problem now. How can I fix it?