Re:dBASE connectivity
| From: | Miles Thompson | Date: | Thu, 04 Jul 2002 18:00:42 +0000 |
| Subject: | Re:dBASE connectivity | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20321@lists.php.net to get a copy of this message | ||
Labrhas,
If you echo $new_record, and $newrecord["name"], what displays? I'm really trying to confirm that $new_record is an array, and that $new_record["name"] contains what you expect. Is it possible that you have to assign like this:
$new_record['name'] = "'xxxxxxxxxx'"; which would put a quoted string in the array. I know this seems weird, but I started with dBase II and I've been working with FoxPro since 1.01 and every so often you get into weird scenarios where the dBase/FP engine thinks you're passing a var not a literal. (This is also "grasping at staws" territory.)I want to reiterate that the dbase functions are not recommended for production work. See the note under dbase. AS an alternative, what about using odbc? You may be able to run an insert query. Miles At 03:17 PM 7/4/2002 +0100, labhras sammin wrote:
thanks for your help I have tested that everything works, valid handles, returned method values, etc. Line 23 is the dbase_add_record line. Do you know of anywhere there may be an example thanks Labhras "Miles Thompson" <milesthompson@ns.sympatico.ca> wrote in message news:5.0.2.1.0.20020704085616.02df1df0@pop1.ns.sympatico.ca... 1. Please don't cross post. 2. Which line is #23? 3. Have you tested to ensure that you have a valid handle? ($db_num) 4. Have you tried adding error code to see the result of dbase_create(), dbase_open() 5. I seem to remember reading in the docs, a long time ago (2 yr) that the dbase functions were not really reliable and were intended mostly to extract info for export to another database. I could not be 100% wrong on that, and I've not worked with the dbase functions in PHP. After this reply, please keep this focused on the php-db list. Regards - Miles Thompson At 12:14 PM 7/4/2002 +0100, labhras sammin wrote:Hi I need to use PHP (ver 4 windows) to add a record to a dBase ivdatabase.I can create, open, read and close a database but when I try to add a record I always get the following error: Warning: unexpected error in C:\php\phpstuff\addTest1.php on line 23 Here is the code [shortened] that I use to create the database table,openthe table, create the record and add the record- the database table hasonefield a 10 char string: $dbname = "test1.dbf"; $dbflag = 2;-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php$def = array( array("name", "C", 10));dbase_create($dbname, $def)); $db_num = dbase_open($dbname, $dbflag); $new_record['name'] = 'xxxxxxxxxx'; dbase_add_record ($db_num, $new_record); any help, advice or code samples would be very appreciated thanks Labhras -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php