473,568 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to escape quotes when passing data to javascript from PHP?

pradeepjain
563 Contributor
Expand|Select|Wrap|Line Numbers
  1. $myPage .= '<td><a href=\'javascript:editProduct('.$row['id'].',"'.htmlentities($row['name'],ENT_QUOTES).'")\'>Edit</a></td>';
  2.  
  3.  
  4. function editProduct(id,name){
  5.         alert(name);
  6.         }

$row['name'] can have value like pradeep"s or pradeep's. so i need to escape these. but its not working. can you please help me with this.
May 4 '11 #1
1 1345
johny10151981
1,059 Top Contributor
use addslashes or mysql_real_esca p_string function
May 6 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1250
by: N Yiannakoulias | last post by:
Hi all, Is there a performance issue when passing data types of different sizes to a function? For example, if a double precision variable is bigger than a single precision variable, is it faster at run time to pass the single precision variable? Let's say the function does the exact same thing in both cases (say, returns an integer). Is...
3
4742
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing around chunks of data in DataTables/DataSets, simply because that was the format that they were in when the data was taken from the database. Now,...
3
12659
by: Brian Smith | last post by:
I have a .aspx page (we'll call it Form1) with a datagrid on it. The datagrid is populated from a dataset that I manually entered data into (the data isn't in a database). The datagrid on Form1 also has a button column on it. I have another .aspx page (Form2) with an unpopulated datagrid on it. I want to populate it with all the columns...
3
2673
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/Anch_EntDevAppArchPatPrac.asp I use my own classes in the Business layer. I want to keep the Data Access layer from requiring these classes so I tried passing a...
1
2187
by: Steve Cosh | last post by:
Hi, is there any way of passing a javascript variable over to a asp variable so i can write it to my database. Thanks
3
3662
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following runtime error, " Attempting to call into managed code without transitioning out first. Do not attempt to run managed code inside low-level native...
1
1276
by: paul | last post by:
I have a user control that uses some javascript to fire a popup which is used for a date picker. The textbox (and the button that fires the popup box) needing to get the date is in a user control which reside in the view of a multiview on a .aspx page. I tried wiring it up with an html input but I can't use the <form> tag on the control...
4
2125
by: Andreas Pfiz | last post by:
Hello, I have a problem with passing Data between a "classic ASP-Page (VBScript)" and a ASP.NET 2.0 Page using showModalDialog / window.returnValue ------------------------------------------------------------- Here is the Code-Snippet from the "caller" page: var rValue="oldValue"; rValue =...
4
4151
by: moondaddy | last post by:
I have a htm page where I need to pass some data to an aspx page as a means of sending data to the database. I don't need to see the aspx page so I was going to put it in a hidden iframe. This works real good. Since I don't need the aspx page to do any postback, is there a way to pass a parameter to it with out it finishing the round trip...
4
3562
by: bokisa | last post by:
Hi, I am having a problem with string property in my custom control. If I use \n \r... special chars in this property, they are replaced with escape quotes. Example: if I set next value: row0\nrow1\nrow2
0
7692
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7913
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6274
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2099
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.