-
$CAT='Bath & Body';
-
sql="select * from Products where Category = '$CAT';
-
$result=mysql_query($sql);
-
When I am running above code , I got an error. When I am removing '&' from $CAT , it is working fine. I wish to know how to include ampersand in mysql data.
Thanks in advance
10 4454 Markus 6,050
Recognized Expert Expert -
$CAT='Bath & Body';
-
sql="select * from Products where Category = '$CAT';
-
$result=mysql_query($sql);
-
When I am running above code , I got an error. When I am removing '&' from $CAT , it is working fine. I wish to know how to include ampersand in mysql data.
Thanks in advance
Try preceeding it with a backslash
[php]
$CAT = "something \& something else";
[/php]
Markus 6,050
Recognized Expert Expert
Sorry. It is not working
Strange
What error do you get?
I am using this php code in a javascript function. I got the error "object expected". When removing ampersand from $CAT or commenting $sql stament, then code is working properly.
Markus 6,050
Recognized Expert Expert
I am using this php code in a javascript function. I got the error "object expected". When removing ampersand from $CAT or commenting $sql stament, then code is working properly.
Can you please show the full code
using the proper code tags
-
-
function removeAllOptions(selectbox)
-
{
-
var i;
-
for(i=selectbox.options.length-1;i>=0;i--)
-
{
-
//selectbox.options.remove(i);
-
selectbox.remove(i);
-
}
-
}
-
-
-
function addOption(selectbox, value, text )
-
{
-
var optn = document.createElement("OPTION");
-
optn.text = text;
-
optn.value = value;
-
-
selectbox.options.add(optn);
-
}
-
-
-
function SelectEditProduct()
-
{
-
removeAllOptions(document.editproducts.productname);
-
addOption(document.editproducts.productname,"","select");
-
<?php
-
include_once("database.php");
-
$sql="select * from ProductCategory ";
-
$result1=mysql_query($sql) ;
-
while ($rows1=mysql_fetch_row($result1))
-
{
-
echo "if(document.editproducts.categoryname.value == '$rows1[1]'){";
-
-
$sql="select * from Products where Category ='$rows1[1]'"; // THIS LINE SHOWS ERROR
-
//$sql="select * from Products where Category='Bath \& Body'";
-
-
$result=mysql_query($sql);
-
while ($rows=mysql_fetch_row($result))
-
{
-
echo "addOption(document.editproducts.productname,'$rows[1]', '$rows[2]');";
-
}
-
echo "}";
-
}
-
-
?>
-
-
}
-
-
ProductCategory table contains some data with ampersand ($rows1[1]). This causes errors
Markus 6,050
Recognized Expert Expert
Can you show me the output you get on the page source?
I'm still not understand your problem.
Is the error with javascript or php?
Markus 6,050
Recognized Expert Expert
It is a javascript error. When we removing $sql ="..." statement, there is no errors. URL of this code is http://www.markdickson.com/adminpanel/editproduct.php
Error occur when we changing productcategory
If it's a javascript error, you should ask in the javascript forum.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Willoughby Bridge |
last post by:
I am trying to post from a form to table using the code below from file2.php
and having two problems:
1. The data is not being posted to the table
2. After submit is pressed the following message comes up: "The page cannot
be displayed" - The browser can't find the file, because it is looking for
http://file2.php instead of http://teachercards.org//file2.php
Any help would be greatly appreciated.
TIA
|
by: funcSter |
last post by:
I want to retrieve data from an Excel file like how I would with a
database. I understand that I would have to use OLE DB. Somehow I
think I cannot get the connection string right, as the bit of code
fails at "objConn.Open()" with the error:
System.Data.OleDb.OleDbException: Could not find installable ISAM.
Can somebody please help me out? I'm still a learning programmer, so
if someone can point out my mistakes, it'll be great! Thanks!
...
|
by: jenese |
last post by:
Hi!
I've searched the forum and the net for the answer of, probably an easy question for the experienced....
I need to limit the amount of text to 50 first characters when looping out the data from a mysql text-table. How and where do I attack this problem? :confused:
Thanks! :cool:
|
by: cool84 |
last post by:
I have a problem to retriew thr .txt file in the mysql table into the temp folder.
anyone know how to do it ?
|
by: djdarpan |
last post by:
Hi,
Can anyone help me!
I have multiple auto generated input fields(e.g. values are 1 to 10) in a form and I want to insert all input fields data in one column of MySQL table. Is there any way to insert these data? Please help me.
Thanks for your help in advance.
Best,
| |
by: printline |
last post by:
Hello All
I need a little help with a phph script to display some specific data from a mysql table.
I have a mysql table with 4 columns and 10 rows. I want to display fx. data from row 4, 6, 8 and 10.
I can display either the first row or all the rows using the below code:
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row. " - ". $row. " <img src=images/arlon.jpg /> ". $row. " - ". $row;
|
by: Nilanjan Sanyal |
last post by:
how to retrieve hindi text from mysql database using php
|
by: amskape |
last post by:
Hi Pals,
I am Anes , from Kerala ,India. I am a PHP Programmer Basically
but have interest and now studying C++ , I plan to
take data from MySql in C++, for that I install mysql-connector-c++-1.1.0-win32.msi
in my Windows XP. I got a Script from net , but it will not Work... Do you
please Explain how to Insert and select data in C++ with the help of a Code
and other things related to the Driver(mysql-connector-c++-1.1.0-win32.msi).
...
|
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: 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: 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: 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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |