PHP3 and ndbm question

From: Date: Tue, 03 Oct 2000 17:46:15 +0000
Subject: PHP3 and ndbm question
Groups: php.db 
Request: Send a blank email to php-db+get-3271@lists.php.net to get a copy of this message
Greetings all, I'm hoping someone out there can help me with a little insight. I'm attempting to put the job postings for my faculty online. The system I've designed is based off of a csv file created from a query in access. I have the file read into a ndbm db file on the web server. The university is running php 3.0.12 on an apache server. OS is solaris 5.6. The idea is that the career services centre simply has to upload one text file for all of the pages to instantly updated with the available postings. Three of the 12 fields that I'm trying to import are memo fields with variable length information. I have the php code being returned to the browser to check that it is working correctly. If I use a text file without the three memo fields the process works perfectly. When I use a text file with the memo fields the dbminsert ( or dbmreplace) function fails. As I'm serializing the array of values being read using fgetcsv() I thought that it could have something to do with a string lenght issue. So I attempted to import a much smaller file containing just the posting date, salary and the three memo fields. This file also fails when the dbminsert function is called. I'm currently stumped. I'm curios if it could have something to do with special characters inside of the memo fields values. Only when the memo fields are included does the dbminsert return that it fails. All other functions being run by php work flawlessly as shown by the values returned to the browser window. A sample can be viewed at http://www.umanitoba.ca/management/groups/umtollef/csc/addtodb.php3 below is the code I'm using in the addtodb.php3 page, as it works with the non memos text file I'm pretty confident that it is correct. Can't comprehend why the dbminsert function refuses to work. <?php // insert path and name of text file to be used in $filename variable $filename = "postings.txt"; // $dbpath sets the path and filename of the unix db created from the text file $dbpath = "webdb"; function import_text() { global $filename, $dbpath; $db = dbmopen($dbpath, "n"); if (!$db) { echo "db open failed"; echo "Program terminated"; } $fp = fopen($filename, "r"); if(!$fp) { dbmclose($db); echo "Cannot open job postings text file $filename"; } $stringkeys = fgetcsv($fp, 1000); $id = 1; $nr_entries = 0; while(!feof($fp)) { $data = fgetcsv($fp, 100000); if(is_array($data) && count($data) > 0 ) { $new = array(); for($i = 0; $i < count($data); $i++) { $new[$stringkeys[$i]] = $data[$i]; } $new["Id"] = $id; while (list ($key, $var) = each ($new) ) { echo "$key &nbsp; $var <br>"; } $serialized = serialize($new); $length = strlen($serialized); echo "$length<br>"; $insertdb = dbminsert($db, $id, $serialized); echo "$insertdb<br><br>"; if ($insertdb = true) { $nr_entries++; } $id++; } } fclose($fp); dbmclose($db); } import_text(); echo "<br><br>"; echo "<a href='jobs_by_company.php3'>Job Postings by Company</a>"; echo "<br><br>"; echo "<a href='jobs_by_title.php3'>Job Postings by Job Titles</a>"; echo "<br><br>"; echo "<a href='jobs_by_date.php3'>Job Postings by Date</a>"; ?> Thanks Geoff Tollefson (204)474-6739 umtollef@cc.umanitoba.ca - until friday Oct 6 then shutdown gtollef@hotmail.com

« previous php.db (#3271) next »