Copy link to clipboard
Copied
Simple querry but when I do this statement:
SELECT NAME, KEYWORDS, `DESCRIPTION`, SKU, MANUFACTURER, PRICE, RETAILPRICE, BUYURL, IMPRESSIONURL, IMAGEURL, ADVERTISERCATEGORY
FROM Cruiser
WHERE ADVERTISERCATEGORY LIKE '%License Plate Frames & Relocation%'
ORDER BY NAME ASC
MySQL Error 1064
You have anerror in your SQL syntax; near "%License Plate Frames' at line 1
Any help would be great
Copy link to clipboard
Copied
Assuming you are using PHP - In PHP the ampersand is a special character so you need to deal with that. I don't know PHP but you could try escaping the ampersand with a backslash : WHERE ADVERTISERCATEGORY LIKE '%License Plate Frames \& Relocation%' or try using htmlentities()
Copy link to clipboard
Copied
The ampersand has nothing to do with the error message. Although the ampersand occasionally has a special meaning in PHP, it doesn't need escaping in a string.
The error message comes from MySQL, which always identifies a SQL error as being "near" something. What that means is that the error immediately precedes whatever follows "near". In this case, the error is "near" %License Plate Frames. In other words, the opening single quote is creating the problem. It would appear there's a problem with matching quotes in the string that passes the SQL query to the database.
Copy link to clipboard
Copied
You might want to post the entire code from the page. This sql SELECT is different the one you originally posted in this thread: http://forums.adobe.com/message/4752558#4752558
Copy link to clipboard
Copied
That is the code. When I dont put the & in on a different query. it works. It's just that when ever i put in the "&" it just gives me the error
Copy link to clipboard
Copied
Without seeing the full code that compiles and submits the query, it's impossible to say what the problem is. Adding an ampersand should not cause a SQL error. I have just tested the following:
$conn = new MySQLi('localhost', 'root', 'secret', 'test');
$result = $conn->query("SELECT * FROM categories WHERE category LIKE 'Rock & %'");
$row = $result->fetch_assoc();
echo $row['category'];
No error is generated, and it displays "Rock & Roll".
Copy link to clipboard
Copied
I put the hole code at the beginning.
Copy link to clipboard
Copied
You have only posted the SQL select statement. You have not posted any of the server side script.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more