View Single Post
  #1 (permalink)  
Old 02-03-07, 02:00 PM
sn0wy sn0wy is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Problem inserting into database

Hey Guys,

Trying to make a script where i just fill a textarea in and sends the text into a database, but the problem i have is when there is any ' in the text i got the error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 're firmly established at the very heart of British life, providing the freshest ' at line 1

but if i dont use ' it goes in fine? Can anyone help?? my text is below

PHP Code:

<?PHP

include ("includes/db.php");

$id2 $_POST['id2'];

$free_text $_POST['free_text'];
$awards_text $_POST['awards_text'];




$table_name "baccount";
      
          
$connection = @mysql_connect($dbserver$dbuser$dbpass) or die ("Couldn't Connect to database");
          
$db = @mysql_select_db($dbname$connection) or die(mysql_error());
          
$sql "UPDATE $table_name set free_text= '$free_text', awards_text= '$awards_text' WHERE id = '$id2'";
          
$result = @mysql_query($sql,$connection) or die(mysql_error()); 
        
          
?>
Can someone have a look at my code and see what i need to do?

Thank you in advanced
__________________
Power is in my programming fingers

Last edited by Nico; 02-03-07 at 02:04 PM. Reason: Fixed [/php] wrapper.
Reply With Quote