Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Merry X mas, How may I insert html into $lang = array_merge (PHP)

array

  • Please log in to reply
12 replies to this topic

#1 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 26 December 2010 - 01:57 AM

here is the original PHP code below, much appreciated in advance

How may I insert html into $lang = array_merge (PHP)



<?php
$lang_ext = array(
'onlinepay' => 'Online payment',
'oid' => 'Order Number:',
'pname' => 'Product Name:',
'onums' => 'Quantity:',
'oprices' => 'Total price:',
'mons' => 'Available balance:',
'rcode' => 'Verification Code:',
'payit' => 'Pay Now',
'npayfor' => 'Price to be paid',
'paym' => 'Do you confirm payment now? ',
'payerror' => 'Please transfer money to your account first, thank you. ',
'fcharge' => 'Please deposit money here ',
);
$lang = array_merge($lang, $lang_ext);
?>

Edited by Orjan, 26 December 2010 - 03:19 AM.

  • 0

#2 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 26 December 2010 - 02:01 AM

How may I insert HTML codes below into the PHP codes above? Thanks a lot

<form method="post" action="www.123648.com/apple" >
<input type="hidden" name="ap_productid" value="mango=="/>
<input type="hidden" name="ap_quantity" value="1"/>
<input type="image" name="ap_image" src="https://www.123648.com/B26C4898CBBE2DD8b0en.gif"/>
</form>

<a href='https://123648.com/applet?CTd5422ZwM='>Mango</a>

Edited by Orjan, 26 December 2010 - 03:20 AM.

  • 0

#3 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 26 December 2010 - 03:23 AM

just set end tags and put your html there, then start your php tags again.
<?php
// some php code
?>html goes here <?php
// more php code
?>


or just echo the html from your php


<?php
// other php
echo '<form method="post" action="http://...">';
// morde php code

  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#4 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 26 December 2010 - 04:05 AM

just set end tags and put your html there, then start your php tags again.

<?php
// some php code
?>html goes here <?php
// more php code
?>


or just echo the html from your php


<?php
// other php
echo '<form method="post" action="http://...">';
// morde php code


Thank you so much but it still does not work with error below

Parse error: syntax error, unexpected T_ECHO, expecting ')' on line 13
  • 0

#5 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 26 December 2010 - 08:01 AM

please show us your new code if you want us to be able to help you
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#6 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 26 December 2010 - 06:37 PM

my original php codes below, thank you

<?php 
$lang_ext = array(
'onlinepay' => 'Online payment',
'oid' => 'Order Number:',
'pname' => 'Product Name:',
'onums' => 'Quantity:',
'oprices' => 'Total price:',
'mons' => 'Available balance:',
'rcode' => 'Verification Code:',
'payit' => 'Pay Now',
'npayfor' => 'Price to be paid',
'paym' => 'Do you confirm payment now? ',
'payerror' => 'Please transfer money to your account first, thank you. ',
'fcharge' => 'Please deposit money here ',
);
$lang = array_merge($lang, $lang_ext);
?>

Edited by Orjan, 27 December 2010 - 07:11 AM.

  • 0

#7 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 26 December 2010 - 06:40 PM

please show us your new code if you want us to be able to help you

thank you again

echo "<form method='post' action='www.123648.com/apple' >";
echo "<input type='hidden' name='ap_productid' value='mango=='/>";
echo "<input type='hidden' name='ap_quantity' value='1'/>";
echo "<input type='image' name='ap_image' src='https://www.123648.com/B26C4898CBBE2DD8b0en.gif'/>";
echo "</form>";
echo "<a href='https://123648.com/applet?CTd5422ZwM='>Mango</a>";

Edited by Orjan, 27 December 2010 - 07:11 AM.

  • 0

#8 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 27 December 2010 - 07:12 AM

hmm.. you did the oposit way that I adviced you to do, use apostrophes around not inside...
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#9 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 28 December 2010 - 08:46 PM

hmm.. you did the oposit way that I adviced you to do, use apostrophes around not inside...


Thank you, Orjan, i will tyr again
  • 0

#10 calm

calm

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 29 December 2010 - 05:24 AM

I have edited with code below but it is still showing the similar error "syntax error, unexpected", however, thanks a lot for your help! ^~^

"echo <form method='post' action='www.123648.com/apple' >";
"echo <input type='hidden' name='ap_productid' value='mango=='/>";
"echo <input type='hidden' name='ap_quantity' value='1'/>";
"echo <input type='image' name='ap_image' src='https://www.123648.com/B26C4898CBBE2DD8b0en.gif'/>";
"echo </form>";
"echo <a href='https://123648.com/applet?CTd5422ZwM='>Mango</a>"
  • 0

#11 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 30 December 2010 - 10:33 AM

yeah, echo shall be outside the string delimiters. also, change to:
echo '<form method="post" action="www.123648.com/apple">';
etc...
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#12 gon1387

gon1387

    CC Regular

  • Member
  • PipPipPip
  • 30 posts
  • Programming Language:C, C++, PHP, JavaScript, Others
  • Learning:C, Java, C++, PHP, Python, JavaScript, Others

Posted 30 December 2010 - 05:41 PM

if you have to echo this as an HTML you have to escape the single quotes like this

echo '<a href=\'https://123648.com/applet?CTd5422ZwM=\'>Mango</a>';

refer to this for information about string literals :)

PHP: Strings - Manual

HAPPY NEW YEAR! :)
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download