-
$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 4437 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.
Thanks a lot for your help
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |