Jump to content

Apostrophe problem


Renegade85

Recommended Posts

Hi, I'm having problems creating a javascript function call using PHP  :(

 

I can't use ' around the string value $row[0] because it closes the javascript method call.

 

print "<td><a href='javascript:addPlayer(" .$row[5] .",'"  .$row[0] ."'," .$row[3] .")'>" .$row [0] . "</a></td> ";

 

This code results in javascript:addPlayer(10,

 

If I take out the single quote, I get this - javascript:addPlayer(10,Evra,7.8 ); //not including the space between 8 and ) 8)

 

The javascript method then fails because Evra is an undefined object :/

 

Anyone have any ideas how I could get around this?

Link to comment
https://forums.phpfreaks.com/topic/192773-apostrophe-problem/
Share on other sites

Was just thinking of other ways to code what I need. Using AJAX to get the player name value ($row[0]) would also work for me.

 

I would rather use the original way of doing it though because it would be more efficient.

 

If you can think of a way around my problem, please let me know or if you think there's no way around the problem, let me know too  ;)

 

 

Link to comment
https://forums.phpfreaks.com/topic/192773-apostrophe-problem/#findComment-1015489
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.