Skip to content
Advertisement

var in textarea from sql?

I tried to make a form with textarea content taken from sql and it’s working well except for 1 thing i want to make…

i have some text in the sql like “hi $name, welcome” (for example) and when i echo it in the textarea i get the same “hi $name, welcome” but i want the $name to change for what i want…

JavaScript

EDIT: that’s what i get: enter image description here

and that’s the sql: enter image description here

how i can change it?

thanks!

Advertisement

Answer

If you want to store a message in the database and replace some words on output, don’t save it as PHP code. Create a template with placeholders for the variable data instead, something like:

JavaScript

and then just replace those using str_replace()

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement