Rahul Sitaram Johari wrote: > Ave, > > Can¹t figure this one out. I¹m using the dbase_replace_record() function to > replace a record in a dbase (.dbf) database. I just want to replace the > value of one of the fields with another value. This is my code: > > $db = dbase_open("CRUMBS.DBF", 2) or die("Fatal Error: Could not open > database!"); > if ($db) { > $record_numbers = dbase_numrecords($db); > for ($i = 1; $i <= $record_numbers; $i++) { > $row = dbase_get_record_with_names($db, $i); > if ($row['PHONE'] == $thekey) { > print_r($row); > $row['A'] == "F"; > dbase_replace_record($db, $row, 1); > } > } > } > dbase_close($db); > > Basically I have a database called ³CRUMBS.DBF², and the record where PHONE > = $thekey, I want to replace the value of the field ³A² with ³F². I keep > getting the error: ³Wrong number of fields specified². > I have over 60 fields in each row and I just want to replace the value of > the field ³A². > > Any suggestions? get a big jar of 'clue'. as in learn to investigate and read ... not having ever used these functions here are my hypotheses based on 5 seconds of investigation and reading: 1. dbase_get_record_with_names() gives a assoc. array - it may also have fields as indexed items in that array (like other DB extensions often do) ergo double the fields that you want. 2. quoting the following page: http://php.net/dbase_get_record_with_names "Return Values An associative array with the record. This will also include a key named deleted which is set to 1 if the record has been marked for deletion" so dbase_replace_record() is possibly seeing 'deleted' as a extra erranous field. 3. maybe looking at and comparing the output of print_r($row), dbase_get_record_with_names($db, $i) and dbase_get_record($db, $i) might tell you something; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php