1

Is there anyway to insert values like ' or " or ` into Mysql or MsSql via php and VB.NET?

It always return an error. Sometimes we must insert these character. In the Phpmyadmin, it can inserts/updated with successfull. But how?

Please help, i am newbie. I cannot search it in MySql/MsSql Dev pages. Thanks

1 Answers1

1

Try using a \ (backslash) in front of the quotes and you should be good to go.

In PHP use the query like this to use mysql QUOTE()

 <?php $query = "
        INSERT INTO
            `mytable`
        SET
            `mycolumn` = QUOTE($myphpvariable)";
 ?>

Or you could use addslashes() in PHP.

$myvariable = addslashes($myvariable);

But what you should REALLY do is use

Prepared Statements.

Tech Savant
  • 3,686
  • 1
  • 19
  • 39
  • But i am insert from php. – Angga Lisdiyanto May 07 '15 at 01:49
  • @AnggaLisdiyanto I have updated my answer. If you find my answer helpful can you click the up arrow next to it, and if you find it to be the answer that solved your question, can you click the check mark to indicate it is a correct answer. Thanks. :) – Tech Savant May 07 '15 at 02:15