Jump to content

[SOLVED] Problems with INSERT and apostrophes.


php_beginner_83

Recommended Posts

Hi All

 

I'm trying to create an upload page (form) where I can add photos (the path of the image) and a description of the photo to a database.  I'm coming across problems when in the 'description'.  If I use ' it creates an error, for example, 'I'm a bear'.  When I use Im a bear, there is no problem.

I'm still fairly new to php and would appreciate any comments on this. 

 

My code is..

 

$insert = "INSERT INTO pictures (ID, Description, Path) VALUES ($newID, '{$_POST['imageDescription']}', '" . $string . "{$_POST['path']}')";

mysql_query($insert) or die(mysql_error());

 

It's this insert where the problem is.

 

Thank you.

Hi

 

Just the part with the apostraphies

 

$insert = "INSERT INTO pictures (ID, Description, Path) VALUES ($newID, '".mysql_real_escape_string($_POST['imageDescription'])."', '" . $string . mysql_real_escape_string($_POST['path'])."')";

 

All the best

 

Keith

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.