-3

I am trying to pass a string in the onClick event handler function's arguments.

I am not able to pass the string to the function, but I am able to pass the number integer to the function.

PHP:

echo '<tr style="background: #D6EAF8" class="clickable-row" OnClick="DisplayEnterOrderModal('.$order["id_order"].','.$order["id_customer"].','.$order[7].','"wanted to be passed"');"  value="'.$order["id_order"].'" > ';

Error:

( ! ) Parse error: syntax error, unexpected '"wanted to be passed"' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C:\wamp32\www\EK\index.php on line 644
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Sabra
  • 177
  • 2
  • 19

2 Answers2

1

You can try this:

Replace '"wanted to be passed"' with "wanted to be passed". Remove extra ' ' single quotes.

Or just escape them \"wanted to be passed\"

I hope this will help you :-)

Pre'P
  • 69
  • 8
-1

echo

    echo '<tr style="background: #D6EAF8" class="clickable-row" OnClick="DisplayEnterOrderModal('.$order["id_order"].','.$order["id_customer"].','.$order[7].','."wanted to be passed"');"  value="'.$order["id_order"].'" > ';

Please try this one, I think this might work.