Anyone on? INSERT INTO with MS Access problem

From: Date: Sun, 01 Oct 2000 21:31:14 +0000
Subject: Anyone on? INSERT INTO with MS Access problem
Groups: php.windows 
Request: Send a blank email to php-windows+get-2864@lists.php.net to get a copy of this message
Hi everyone: I'm having some problems and I'm out of guesses... I'm attempting my first INSERT INTO with MS Access. I've had wonderful successes with SELECT and then using that info. But I'm really quite stuck here. My first problem is getting the date to not break the INSERT INTO sql. When I have date and '$date' in the INSERT INTO sql, I get this error: Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLPrepare in D:\InetPub\wwwroot\is\website\test_center\newsinputter.php on line 85 otherwise it doesn't error out BUT BUT BUT BUT It doesn't put the data into the table either!!!! no error, but no data either! Arrrgh! Any Suggestions? Thanks in advance, John Code Below ------------- <?php //check date //yes, Friedl's book will teach you how to make regexes like this too! if ( !ereg ("(0?[0-9]|1[0-2])[-/]([0-2]?[0-9]|3[01])[-/]([0-9]{4})", $date ) ) { //date is invalid die ("Please press your browser's back button and enter a date in the format MM-DD-YYYY"); } // create connections $connection = odbc_connect("web.mdb","",""); // test connection if (!$connection) { echo "Couldn't make a connection!"; exit; } echo "TESTING: $date <br> $headline <br> $place <br> $author <br> $story <br><br><br>"; /* I'll look into these functions a little deeper later function AccessAddSlashes($S) { $S=str_replace("\\'","''",$S); $S=str_replace("\\\"","\"\"",$S); return $S; } function AccessStripSlashes($S) { $S=str_replace("\"\"","\\\"",$S); $S=stripslashes($S); return $S; } */ $headline = stripslashes ($headline); $place = stripslashes ($place); $author = stripslashes ($author); $story = stripslashes ($story); echo "TESTING AFTER SLASH STRIP: $date <br> $headline <br> $place <br> $author <br> $story <br>"; // create SQL statement ******(this errors out if I put date and '$date' into the fields and values)***** $sql = "INSERT INTO FrontpageNews (headline,place,author,story) VALUES ('$headline','$place','$author','$story');"; // prepare SQL statement $sql_insert = odbc_prepare($connection,$sql); /* execute SQL statement and get results odbc_execute($sql_insert); */ /* check for errors */ if (!odbc_execute($sql_insert)) { /* error */ echo "Whoops"; } else { echo "You did it!"; } odbc_close($connection); ?> --------------------- Founder and Only Member of The 'What Kind of Idiot Uses PHP with IIS with Oracle on NT?' Consortium John Asendorf - jasendorf@lcounty.com Web Applications Developer http://www.lcounty.com - NEW FEATURES ADDED DAILY! Licking County, Ohio, USA 740-349-3631

« previous php.windows (#2864) next »