| Author |
Message |
Scott tutorialtoday.com

Joined: 24 Mar 2005 Posts: 2627 Location: Mississauga, Ontario
|
Posted: Tue Feb 12, 2008 6:14 pm Post subject: Inserting variables in strings in PHP |
|
|
I released a script for upgrading the version of a script which people downloaded. In the upgrade it inserted a template (which consists of HTML and variables) into MySQL. I tested it and it worked fine for me but for a few people, when they upgraded and used the template, the spot where the variables would be were now blank.
So I am guessing the problem was probably that PHP tried to parse those variables when inserting it, even though they were inside a string. I searched around and I found in a comment on php.net that a variable in double quotes will be parsed, a variable in single quotes will not be and an escaped (\ before $) will not be parsed.
Which proved to be true after I doing so on this host's PHP 5 and 4. Although, the thing is, the upgrade script did have the values wrapped in single quotes, yet some people still had problems, could there be a PHP setting or a certain version that could be causing this?
Then again this might not even be the problem, I can't really tell because I don't have any on this host. _________________ Tutorial Management Script - Version 1.4 Released
TutorialToday - Up and running, submit your tutorials!
Linux Tutorials - Coming Soon |
|
| Back to top |
|
| |
krt ...

Joined: 11 Jan 2005 Posts: 4695 Location: Down Under
|
Posted: Wed Feb 13, 2008 6:12 am Post subject: |
|
|
Sorry, I'm confused. Why is the database involved?
Are you trying to do something like a patch file, e.g.
- some obsolete line
- some obsolete line
+ new line
+ new line
@ reference line(s)
+ new line
+ new line
For reference:
'literal $variable in single quotes'
"literal \$variable in double quotes"
There is no setting that would allow variables in single quotes to be parsed as such. I'd say callbacks and evaluated code is not relevant here so I have no idea what would be causing the problems mentioned. |
|
| Back to top |
|
| |
Scott tutorialtoday.com

Joined: 24 Mar 2005 Posts: 2627 Location: Mississauga, Ontario
|
Posted: Wed Feb 13, 2008 6:49 am Post subject: |
|
|
The HTML and CSS are stored in the database for easy editing, it is a styling system similar to vBulletin where you have templates which show in certains spots on certain pages, and there are variables which are parsed by the script to make the templates dynamic. _________________ Tutorial Management Script - Version 1.4 Released
TutorialToday - Up and running, submit your tutorials!
Linux Tutorials - Coming Soon |
|
| Back to top |
|
| |
|
|
|