i am trying to run a SQL query which inserts data about DVDs from amazon.com into a database table.
here is my code:
$conn=odbc_connect('DVDLobby','','');
$sql="INSERT INTO tblDVD(dvdID,UPC,Title,SortTitle,Rating,Released,RunningTime,Overview,FrontImageURL,MovieLocation,CollNumber,PurchaseDate,ChangerNumber,changerLocation)
VALUES('$myUPC.','$myUPC','$myMovieTitle','$myMovieTitle','$myRating',$myReleaseDate,'$myRunningTime','$myDescription','$myImageURL','Hard Drive',1,$today,0,0)";
$rs=odbc_exec($conn,$sql);
basically just a standard insert query.
problem is that sometimes when i run it, i get an error like this:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Destined to become a holiday perennial, <I>The Polar Express</I> also heralded a brave new world of all-digital filmmaking. Critics and audiences were divided between those who hailed it as an instant classic that captures the visual splendor and evocative '., SQL state 37000 in SQLExecDirect in C:\MovielistSite\backend\addmovie2.php on line 37
my guess is that it is choking on the description field which often contains various punctuation and HTML code. so i am thinking it hits a quote or comma or something and causes problems - sql thinks its another field or something.
if thats the case how could i make it so that i can insert a string like this(with punctuation and other special characters) and not cause problems?