0

Hi again here to ask you for a problem solved in first part on my first question. i've a form that submit data via jQuery to a php page, the code:

var messaggio = $("input[name='messaggio']").val();
$.ajax({
   url:"js/php/sendchat.php",
   data:"messaggio="+messaggio,
   type:"post",
   success:function(data){
      $("input[name='messaggio']").val("");
      $("body").html(data);
   }
});

When i check send via jQuery, there's no output, and I still cannot understand why. Here's my php:

$Msg=mysql_real_escape_string(htmlspecialchars($_POST['messaggio']));
if(substr($Msg,0,1 == "§")){echo $Msg;}

The output didn't show §Test that's the thing I wrote on input form, i think that this have not sense. Thank you again for your help.

0

3 Answers 3

3

You didn't close substr

if( substr($Msg, 0, 1) == "§" ) {
     echo $Msg;
}
Sign up to request clarification or add additional context in comments.

Comments

0

mysql_real_escape_string() only works if you have a connection open to the database, or if it can open one. Assuming that is your whole code, it's probable you do not have such a connection, so it is returning false.

1 Comment

I checked the open connection path is correct and i tried to delete mysql_real_escape_string() :)
0

Found a solution using mb_string accuratly.

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.