Jump to content


Photo

Please help me with the following php coding


  • Please log in to reply
5 replies to this topic

#1 mga

mga
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 August 2006 - 01:47 AM

$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,




#2 switchdoc

switchdoc
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationColorado

Posted 21 August 2006 - 02:25 AM

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?

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 August 2006 - 02:31 AM

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.
Legend has it that reading the manual never killed anyone.
My site

#4 mga

mga
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 August 2006 - 02:38 AM

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,

#5 mga

mga
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 August 2006 - 02:57 AM

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,


#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 August 2006 - 09:07 AM

Remove the PHP tags as you are already in php mode:

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


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

Is that what you want?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users