apostrophe in mysql/php
Posted
by fusion
on Stack Overflow
See other posts from Stack Overflow
or by fusion
Published on 2010-04-05T14:08:19Z
Indexed on
2010/04/05
14:13 UTC
Read the original article
Hit count: 585
i'm trying to learn php/mysql.
inserting data into mysql works fine but inserting those with apostrophe is generating an error. i tried using mysql_real_escape_string, yet this doesn't work.
would appreciate any help.
<?php
include 'config.php';
echo "Connected <br />";
$auth = $_POST['author'];
$quo = $_POST['quote'];
$author = mysql_real_escape_string($auth);
$quote = mysql_real_escape_string($quo);
//**************************
//inserting data
$sql="INSERT INTO Quotes (vauthor, cquotes)
VALUES ($author, $quote)";
if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
...
what am i doing wrong?
© Stack Overflow or respective owner