Ampersand in mySQL query strip off remaining value

Whenever I try to insert text that contains an ampersand (&), the ampersand and the rest of the text that appears after it will be disabled.

$int = 0; $string = "You & I!";

$sql = "INSERT INTO `table` VALUES(?,?);";
$prepare = $connect -> prepare( $sql );
$prepare -> bind_param( "is", $int, $string );

// ETC.

      

Even if I run away (which I hate because it adds extra backstrokes to the quotes):

$string = $connect -> real_escape_string( $string );

      

The table will only be inserted You

. The field is set as VARCHAR(100)

.

I cannot convert ampersand to HTML ( &

) object before because the database is also used by WIN32 applications. Getting WIN32 applications to convert an object to a regular character is something I currently have no control over.

What am I doing wrong?

+3


source to share


1 answer


I know you cannot use &

in your database, but if you try it, does it work? It is not clear how your PHP application connects to MySQL, but if it is RESTful then I suspect the ampersand is being interpreted as a delimiter.



0


source







All Articles