RE: Re[2]: [PHP-WIN] Anyone on? INSERT INTO with MS Access proble m
| From: | Asendorf, John | Date: | Sun, 01 Oct 2000 22:45:04 +0000 |
| Subject: | RE: Re[2]: [PHP-WIN] Anyone on? INSERT INTO with MS Access proble m | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-2868@lists.php.net to get a copy of this message | ||
Gonzalo,
Thanks for all of your help. I'm just about at wits end. Your direct email
address doesn't work, so I have to post to the list.
Could you check the properties on your date field in Access? Particularly
your "Format:"
I really don't know how this would make much difference, but I'll try just
about any avenue now.
Going to check the "UPDATE" right now...
John
---------------------
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: Gonzalo Vera [mailto:gvz@eucalipto.net]
> Sent: Sunday, October 01, 2000 6:23 PM
> To: Asendorf, John
> Subject: Re[2]: [PHP-WIN] Anyone on? INSERT INTO with MS
> Access problem
>
>
> Here's an actual example of what was sent (and actually taken) by
> Access.
>
> insert into [préstamos] (LClave, LCopia, Centro, Contacto, Fecha)
> values
> ('G-2/78','11','AM','Myself','1-Oct-00');
>
> As you can see my date format is wildly off standard, but I just
> noticed that the Access manual says that when using SQL statements
> you should use US format (strange, as my non-US format is working),
> soooo... at least the manual is one place not to look for help in this
> case :-/
>
> Why not try YYYY-MM-DD format, Unix style? I've sucesfully used it
> also, both insert and update. Frankly, I don't think format is the
> problem, but, nothing to lose.
>
> Gonzalo.
>
> > I'm afraid that that didn't do the trick...
>
> > could it be my date format: 07-19-1971 for instance?
>
> > ---------------------
> > 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: Gonzalo Vera [mailto:gvz@eucalipto.net]
> >> Sent: Sunday, October 01, 2000 5:37 PM
> >> To: Asendorf, John
> >> Cc: PHP Windows
> >> Subject: Re: [PHP-WIN] Anyone on? INSERT INTO with MS
> Access problem
> >>
> >>
> >> I usually enclose date data in #, like:
> >>
> >> > $sql = "INSERT INTO FrontpageNews (headline,place,author,story,
> >> > date) VALUES
> >> > ('$headline','$place','$author','$story',
> #$date#);";
> >>
> >> That's the way Access likes to recognize dates.
> >>
> >> Gonzalo.
> >>
> >> > 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);5
> >> > $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 FrontpageNews8
> >> (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
> >>
> >>
> >>
> >> --
> >> 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
> >>
>
>