RE: Re[4]: [PHP-WIN] Anyone on? INSERT INTO with MS Access proble m

From: Date: Sun, 01 Oct 2000 23:45:56 +0000
Subject: RE: Re[4]: [PHP-WIN] Anyone on? INSERT INTO with MS Access proble m
Groups: php.windows 
Request: Send a blank email to php-windows+get-2874@lists.php.net to get a copy of this message
OOOOPs, Allow me to finish.... > So far I've determined that it doesn't like $date to show up as #10-10-99# '10-10-99' #10-10-1999# '10-10-1999' #1999-10-10# '1999-10-10' #10/10/1999# '10/10/1999' --------------------- 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: Asendorf, John > Sent: Sunday, October 01, 2000 7:43 PM > To: Gonzalo Vera; Asendorf, John > Cc: php-windows@lists.php.net > Subject: RE: Re[4]: [PHP-WIN] Anyone on? INSERT INTO with MS Access > proble m > > > Gonzalo, > > NOTE: I can't seem to mail directly to you. Keeps mail to > you back as undeliverable. > > I turned on ODBC error tracing to see if I could figure out > what the deal is... > > So far I've determined that it doesn't like > > > --------------------- > 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 7:34 PM > > To: Asendorf, John > > Cc: php-windows@lists.php.net > > Subject: Re[4]: [PHP-WIN] Anyone on? INSERT INTO with MS > > Access proble m > > > > > > John: > > > > I took a little to answer 'cause I went jogging: sunday > exercise keeps > > mind clear :-))) Only four miles, mind you. > > > > My format field has "d-mmm-yyyy", but I don't think that has any > > particular importance, since Access only uses it for the default > > display format inside Access: not through ODBC, not for data > > acquisition. I think Ermanno is closer with the american > format issue. > > Ermanno, are you using Access 97 or 2000? That could be a > difference. > > > > You could also try the datevalue function Ermanno mentions, as a > > matter of fact, you can use any of Access' functions through ODBC. > > > > Boy, this is a weird problem. Could it be some global configuration, > > like # not being the character used for dates? I don't know if you > > could change that, but I'd start looking somewhere else outside > > Access. > > > > Gonzalo. > > > > > Gonzalo, > > > > > Could I ask you to see what you have your Fecha field > > properties set to in > > > Access? Particularly the "Format:" 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: 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 > > >> >> > > >> > > >> > > > > > -- > > > 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 > > >

« previous php.windows (#2874) next »