mysql error, i need help pls
Posted: Fri May 22, 2009 5:28 am
hello everyone..
well, im making a simple chatroom..
here my problem:
if $message contains a " ' " (ex. I'm here).. this generate an error in the insert statement..
when $message doesnt contain " ' ", its works fine..
btw, the $message is a LONGTEXT.. does it matter.. but I changed it to MEDIUMTEXT and TEXT but it still have that error when $message contains " ' "
thanks in advance
well, im making a simple chatroom..
Code: Select all
<?php
require '../db/db_connect.php';
require '../db/session.php';
$id=$_SESSION['id'];
$message=$_POST['message'];
if($message==null)
header("Location: ../messagearea.php");
else
{
$time = date('Y').date('m').date('d').date('h').date('i').date('s');
$insert1 = "INSERT INTO mainchat
(mainID, chatID, maintime, message) VALUES
('', '$id', '$time', '$message')";
if(!mysql_query($insert1))
{ die(mysql_error()); }
else
{ header("Location: ../messagearea.php"); }
?>
if $message contains a " ' " (ex. I'm here).. this generate an error in the insert statement..
when $message doesnt contain " ' ", its works fine..
btw, the $message is a LONGTEXT.. does it matter.. but I changed it to MEDIUMTEXT and TEXT but it still have that error when $message contains " ' "
thanks in advance