Jump to content

Archived

This topic is now archived and is closed to further replies.

mga

Please help me with the following php coding

Recommended Posts

$vv2='variable2<input type="text" name="vars2" size="30" value="<?php
echo htmlspecialchars($var2 ); ?>"> ';

Please tell me what is wrong with this code, actually i want to save the value of $var2 in mysql db,but the above code is saving "<?php echo htmlspecialchars($var2 ); ?>"  into mysql db.

I appreciate your help.

Thanks,


Share this post


Link to post
Share on other sites
I don't have an exact answer, but I am wondering why you have to save the <?php into the variable.

If you are reading the string, shouldn't you already be in a <?php tag?

Share this post


Link to post
Share on other sites
What's wrong with the "code" you posted is that - as posted - all it does is try to set the variable $vv2 to a rather odd string. The other oddity is that the embedded input has the name vars2 but tries to echo the value of var2 acquired from who knows where.

On balance, I think we need to know a bit more about the code if we're to provide constructive help.

Share this post


Link to post
Share on other sites
The value of $var2 will be html/url string, i thought to use funcation "htmlspecialchars" 
i have to use the php tag. if you have any sample code to store the html and url values
in mysql db,could you please send to me.

Thanks,

Share this post


Link to post
Share on other sites
Actually i want to store the htmlspecialchars value of $var2  into the variable $vv2,
for that i used value="<?php echo htmlspecialchars($var2 ); ?>"

if the above is not correct,could you please let me know the syntax for that.

Thanks,

Share this post


Link to post
Share on other sites
Remove the PHP tags as you are already in php mode:

[code=php:0]$vv2 = 'variable2<input type="text" name="vars2" size="30" value="' . htmlspecialchars($var2) . '">';[/code]


If you want to add a variable to a string use the concatenation operator (.)

Is that what you want?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.