RE: [PHP-WIN] Re: Anyone on? INSERT INTO with MS Access problem
| From: | Jeroen ten Berge | Date: | Mon, 02 Oct 2000 13:37:52 +0000 |
| Subject: | RE: [PHP-WIN] Re: Anyone on? INSERT INTO with MS Access problem | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-2877@lists.php.net to get a copy of this message | ||
Make sure u use the latest JET engine from MS, i beleive it's currently 4.x
-----Original Message-----
From: Asendorf, John [mailto:JAsendorf@lcounty.com]
Sent: Monday, October 02, 2000 3:32 PM
To: php-windows@lists.php.net
Subject: RE: [PHP-WIN] Re: Anyone on? INSERT INTO with MS Access problem
Well, I've been reduced to my lowest level of incompetency...
Anyone else have some input here?
I'm thinking that perhaps I have a bad ODBC Access driver... anyone know
anything about these drivers?
I currently am using ODBC MS Access driver version 4.00.3711.08
I can't even get a date into a new database with a new table that only has a
date field with this sql
$sql = "INSERT INTO Datetest (date) VALUES (#$date#);";
or
$sql = "INSERT INTO [Datetest] (date) VALUES (#$date#);";
If anyone has anything on this, please let me know.
BTW, I can INSERT INTO tables without any problem, UNLESS it's a date
field...
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
> -----Original Message-----
> From: Bob Hall [mailto:bobhall@clark.net]
> Sent: Sunday, October 01, 2000 8:30 PM
> To: php-windows@lists.php.net
> Cc: JAsendorf@lcounty.com
> Subject: [PHP-WIN] Re: Anyone on? INSERT INTO with MS Access problem
>
>
> Instead of '$date', use #$date#. The Jet Database Engine requires all
> dates to be enclosed in pound signs.
>
> Bob Hall
>
> >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);
> >
> >?>
> >
>
> Know thyself? Absurd direction!
> Bubbles bear no introspection. -Khushhal Khan Khatak
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
For additional commands, e-mail: php-windows-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net