Re: [PHP-DB] Re: Storing Variable Function Info
You're trying to use double quotes, in which the variable is evaluated and the stored value is shown, right? Try using single quotes. For example, with $name = Martin. echo My name is $name.; OUTPUT: My name is Martin. echo 'My name is $name.'; OUTPUT: My name is $name. It's interpreted literally, so you could store it in your database as such. HTH Martin Clifford Homepage: http://www.completesource.net Developer's Forums: http://www.completesource.net/forums/ Raquel Rice [EMAIL PROTECTED] 07/24/02 04:49PM On Wed, 24 Jul 2002 13:23:54 +1200 David Robley David Robley [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... I've run out of ideas. I want to store a variable name and a function call in a text column of a MySQL database and have them interpreted at runtime, but I can't figure out how to do it. Examples: This is the $nbrtimes you've asked. and $answer is the square root of sqrt($nbr). I've tried to figure out eval() but don't seem to be able to make it work either. Any ideas? Perhaps if you can show what you have tried and the problem you have had, someone may be able to help you further. -- David Robley I'm sorry to hear that you don't know how to store a variable name in a database and then evaluate that same variable name as a variable after it's retrieved from the database. Maybe someone else will have an idea? -- Raquel As a rule, there is no surer way to the dislike of men than to behave well where they have behaved badly. --Lew Wallace -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Storing Variable Function Info
On Wed, 24 Jul 2002 16:49:38 -0400 Martin Clifford Martin Clifford [EMAIL PROTECTED] wrote: You're trying to use double quotes, in which the variable is evaluated and the stored value is shown, right? Try using single quotes. For example, with $name = Martin. echo My name is $name.; OUTPUT: My name is Martin. echo 'My name is $name.'; OUTPUT: My name is $name. It's interpreted literally, so you could store it in your database as such. HTH Martin Clifford Thank you, Martin, for your informative response. If I understand correctly what you're saying, it would work to do (in psuedo code and reduce to simplest form): store_to_db(text = My name is $name.) The at runtime I could do: get_from_db(text) $name = 'Raquel' echo My name is $name OUTPUT: My name is Raquel Is that correct? What I'm trying to do is to create a web page where users can create their own page text, store it into a database along with certain available variables or functions, then display that page. -- Raquel As a rule, there is no surer way to the dislike of men than to behave well where they have behaved badly. --Lew Wallace -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Storing Variable Function Info
On Thursday 25 July 2002 05:11, Raquel Rice wrote: Thank you, Martin, for your informative response. If I understand correctly what you're saying, it would work to do (in psuedo code and reduce to simplest form): store_to_db(text = My name is $name.) Here $name will be evaluated and stored. Thus if $name was empty/not defined then it would store My name is .. If $name was defined as eg. 'Tom', then text stored would be My name is Tom.. The at runtime I could do: get_from_db(text) Would retrieve whatever you stored, ie: My name is . or My name is Tom. $name = 'Raquel' echo My name is $name OUTPUT: My name is Raquel Is that correct? Therefore it will not work. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The trouble with heart disease is that the first symptom is often hard to deal with: death. -- Michael Phelps */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php