Reputation: 906
what is wrong with this query?
ALTER TABLE test_table
CHANGE text_string text_string VARCHAR(255)
COLLATE utf8_unicode_ci NOT NULL
COMMENT 'hey here are mysql comments..' ;
in PHPMyAdmin it runs fine, but if i execute this query from my PHP class, it returns this:
error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<br>' at line 1
note there is a <br>
tag in the mysql error, I assume its from mysql itself as I always use <br />
. I have searched through my code for a <br>
too so its not me. Im probably just tired and thats in all mysql errors!
I have been on this now for a while, so why does mysql not like this query? Fresh eyes much appreciated!
PHP handler to run the generated query:
$q = isset($_POST['q']) ? base64_decode(($_POST['q'])): false;
$db->q($q) or die("error: ".mysql_error());
yes, the base64_decode is working right.
$q output:
decoded query
ALTER TABLE sNOWsh_amb_nicks_1st_test_table CHANGE text_string text_string VARCHAR(255) collate utf8_unicode_ci NOT NULL COMMENT 'hey here are mysql comments..' ;
Upvotes: 1
Views: 85
Reputation: 782785
When I decode that bas64 string, it ends with ;<br />
. If you're using PHP to display it, make sure you use htmlentities
, otherwise the browser will translate the <br />
to a newline and you won't see it.
You need to look at the application that's sending the POST data. It looks like it's constructing HTML from its input, so newlines are being converted to <br />
.
Upvotes: 5