mga Posted August 21, 2006 Share Posted August 21, 2006 $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, Quote Link to comment https://forums.phpfreaks.com/topic/18150-please-help-me-with-the-following-php-coding/ Share on other sites More sharing options...
switchdoc Posted August 21, 2006 Share Posted August 21, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/18150-please-help-me-with-the-following-php-coding/#findComment-77841 Share on other sites More sharing options...
AndyB Posted August 21, 2006 Share Posted August 21, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/18150-please-help-me-with-the-following-php-coding/#findComment-77843 Share on other sites More sharing options...
mga Posted August 21, 2006 Author Share Posted August 21, 2006 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 valuesin mysql db,could you please send to me.Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/18150-please-help-me-with-the-following-php-coding/#findComment-77847 Share on other sites More sharing options...
mga Posted August 21, 2006 Author Share Posted August 21, 2006 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, Quote Link to comment https://forums.phpfreaks.com/topic/18150-please-help-me-with-the-following-php-coding/#findComment-77856 Share on other sites More sharing options...
wildteen88 Posted August 21, 2006 Share Posted August 21, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/18150-please-help-me-with-the-following-php-coding/#findComment-77952 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.