473,699 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

563 Contributor
Expand|Select|Wrap|Line Numbers
  1. $myPage .= '<td><a href=\'javascript:editProduct('.$row['id'].',"'.htmlentities($row['name'],ENT_QUOTES).'")\'>Edit</a></td>';
  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 1349
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

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 this a compiler-specific issue, or is there a rule of thumb applicable to C? N
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, I know this maybe a pretty silly question with a standard "it depends" answer, but I'm going to...
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 from the row where the button was clicked on Form1. I know how to do what I want with the datagrid
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 Datarow between the layers and it seems to work good for me. Constructing the datarow in the Class...
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
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 extensibility points, such as the vectored exception handler, since doing so can cause corruption...
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 (runtime error for to many <form> tags since the aspx page has one). So I'm trying to figure out a way...
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 = showModalDialog(test.aspx?,'Name','dialogHeight:400px; dialogWidth:800px;');
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 back to the htm page? Thanks. -- moondaddy@newsgroup.nospam
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
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 usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.