0

So maybe im just dumb or tired right now and am missing the obvious or whatever but why is this mysql insert cutting the string off at the double quotes (")>

the contents of the posted field is: It's my text "quote"

$gpCaption = mysql_real_escape_string ($_POST['gpCaption']);

$sql = "INSERT INTO galleriesphotos SET gpID = '$gpID', gID = '$gID', gpCaption = '".$gpCaption."'";
$rows = $db->query($sql);
}

Only this gets inserted into mysql: It\'s my text \

what happened to the rest of it?

2
  • How are you reading it back from the database and displaying it? Commented Apr 19, 2012 at 18:49
  • Looks like a possible magic_quotes issue? (will those ever go away?) What happens if you print $sql? What happens if you change the structure to this: "INSERT INTO galleriesphotos SET gpID = '$gpID', gID = '$gID', gpCaption = '{$gpCaption}'"; What happens if you put in a debug breakpoint and look at the value of $gpCaption? (or var_dump()?) Commented Apr 19, 2012 at 18:58

1 Answer 1

1

Are you sure it is cutting? if $_POST['gpCaption'] is =

It's my text "quote"

This escaping result of this is:

$gpCaption = mysql_real_escape_string ($_POST['gpCaption']);

It\'s my text \"quote\"

And when I insert it in a table, I can see it without a cutoff:

ID FIELD

1 It's my text "quote"

Here is the sql fiddle test:

http://sqlfiddle.com/#!2/e5059/1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.