Jump to content

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

- - - - -

  • Please log in to reply
12 replies to this topic

#1
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts
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.


#2
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts
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.


#3
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
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

__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#4
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts

Orjan said:

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

#5
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
please show us your new code if you want us to be able to help you
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#6
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts
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.


#7
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts

Orjan said:

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.


#8
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
hmm.. you did the oposit way that I adviced you to do, use apostrophes around not inside...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#9
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts

Orjan said:

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

Thank you, Orjan, i will tyr again

#10
calm

calm

    Newbie

  • Members
  • PipPip
  • 16 posts
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>"

#11
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
yeah, echo shall be outside the string delimiters. also, change to:
echo '<form method="post" action="www.123648.com/apple">';
etc...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#12
gon1387

gon1387

    Newbie

  • Members
  • PipPip
  • 17 posts
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! :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users