|
heheheh..thanx Sir..
this is the code Sir..
I don't know where is the wrong code,
because I think it's already right n it have used by another person n when I just try I can't..
sorry if u feel bothered..
<?php
class dbf_class {
var $dbf_num_rec;
var $dbf_num_field;
var $dbf_names = array();
var $_raw;
var $_rowsize;
var $_hdrsize;
var $_memos;
function dbf_class($filename) {
if (!file_exists($filename)) {
echo "<script>alert('Masukkan data DBF')</script>";
} else {
$handle = fopen($filename, "r");
}
if (!$handle) {
echo "Cannot read DBF file";
}
$filesize = filesize($filename);
$this->_raw = fread($handle, $filesize);
fclose($handle);
$arrHeaderHex = array();
for ($i = 0; $i < 32; $i++) {
$arrHeaderHex[$i] = str_pad(dechex(ord($this->_raw[$i])), 2, "0", STR_PAD_LEFT);
}
$line = 32;
$this->dbf_num_rec = hexdec($arrHeaderHex[7] . $arrHeaderHex[6] . $arrHeaderHex[5] . $arrHeaderHex[4]);
$this->_hdrsize = hexdec($arrHeaderHex[9] . $arrHeaderHex[8]);
$this->_rowsize = hexdec($arrHeaderHex[11] . $arrHeaderHex[10]);
$this->dbf_num_field = floor(($this->_hdrsize - $line ) / $line);
for ($j = 0; $j < $this->dbf_num_field; $j++) {
$name = '';
$beg = $j * $line + $line;
for ($k = $beg; $k < $beg + 11; $k++) {
if (ord($this->_raw[$k]) != 0) {
$name .= $this->_raw[$k];
}
}
$this->dbf_names[$j]['name'] = $name;
$this->dbf_names[$j]['len'] = ord($this->_raw[$beg + 16]);
$this->dbf_names[$j]['type'] = $this->_raw[$beg + 11];
}
if (ord($this->_raw[0]) == 131) {
$tail = substr($tail, -1, 1);
if ($tail == 'F') {
$tail = 'T';
} else {
$tail = 't';
}
$memoname = substr($filename, 0, strlen($filename) - 1) . $tail;
$handle = fopen($memoname, "r");
if (!$handle) {
echo "Cannot read DBT file";
exit;
}
$filesize = filesize($memoname);
$this->_memos = fread($handle, $filesize);
fclose($handle);
}
}
function getRow($recnum) {
$memoeot = chr(26) . chr(26);
$rawrow = substr($this->_raw, $recnum * $this->_rowsize + $this->_hdrsize, $this->_rowsize);
$rowrecs = array();
$beg = 1;
if (ord($rawrow[0]) == 42) {
return false;
}
for ($i = 0; $i < $this->dbf_num_field; $i++) {
$col = trim(substr($rawrow, $beg, $this->dbf_names[$i]['len']));
if ($this->dbf_names[$i]['type'] != 'M') {
$rowrecs[] = $col;
} else {
$memobeg = $col * 512;
$memoend = strpos($this->_memos, $memoeot, $memobeg);
$rowrecs[] = substr($this->_memos, $memobeg, $memoend - $memobeg);
}$beg+=$this->dbf_names[$i]['len'];
}
return $rowrecs;
}
function getRowAssoc($recnum) {
$rawrow = substr($this->_raw, $recnum * $this->_rowsize + $this->_hdrsize, $this->_rowsize);
$rowrecs = array();
$beg = 1;
if (ord($rawrow[0]) == 42) {
return false;
}
for ($i = 0; $i < $this->dbf_num_field; $i++) {
$col = trim(substr($rawrow, $beg, $this->dbf_names[$i]['len']));
if ($this->dbf_names[$i]['type'] != 'M') {
$rowrecs[$this->dbf_names[$i]['name']] = $col;
} else {
$memobeg = $col * 512;
$memoend = strpos($this->_memos, $memoeot, $memobeg);
$rowrecs[$this->dbf_names[$i]['name']] = substr($this->_memos, $memobeg, $memoend - $memobeg);
}
$beg+=$this->dbf_names[$i]['len'];
}
return $rowrecs;
}
}
?>
|
|
|
|
|
Hmmm. Okay - that was actually the class I was going to recommend you use.
Now then, the text "length" appears in that document 3 times - each of these are in the comments.
I also see that it doesn't include any other php files, so I can only deduce that the error message is coming from MySql itself. Its very difficult to tell, since you didn't copy/paste the exact error message. (I doubt the error message is going to spell 'length' as 'lenght' )
This makes me consider the possibility that there is in fact, nothing wrong with this code, and that the problem lies in the database structure.
Another alternative is that (& I don't know) perhaps the FoxPro database has a field with NULL in it and you're trying to insert that, but since there's no value, an empty parameter is being passed to mysql, rather than a zero or NULL value..
However, since the code has been around for so long, (at least since 2004) it seems unlikely that it still has an error.
I see that you've made this modification:
if (!file_exists($filename)) {
echo "<script>alert('Masukkan data DBF')</script>";
}
In the original code, there is an exit statement in that block, so that execution wont continue if there's a problem. In your case, it does! (continue if there's a problem)
I'd change that quick-smart!
if (!file_exists($filename))
{
echo 'Masukkan data DBF'"
exit;
}
I suggest that you add some more printf/echo statements to the class to let you know when execution passes certain arbitrary points. A good first location would be after the file has been read and then closed.
At least then you can know where processing gets to before failure - this lets you know which data is being processed at this point and dismiss or confirm that it's the data.
But in any case, often a quick way is to add more echo statements so you know where execution fails.
Good luck.
|
|
|
|
|
thanx sir..
Sir, finally this is the error when I browse the file .DBF...
A PHP Error was encountered
Severity: Warning
Message: fopen(DRBS.DBF) [function.fopen]: failed to open stream: No such file or directory
Filename: models/dbf_class.php
Line Number: 18
Cannot read DBF file
A PHP Error was encountered
Severity: Warning
Message: filesize() [function.filesize]: stat failed for DRBS.DBF
Filename: models/dbf_class.php
Line Number: 22
A PHP Error was encountered
Severity: Warning
Message: fread() expects parameter 1 to be resource, boolean given
Filename: models/dbf_class.php
Line Number: 23
A PHP Error was encountered
Severity: Warning
Message: fclose() expects parameter 1 to be resource, boolean given
Filename: models/dbf_class.php
Line Number: 24
|
|
|
|
|
Susy Nainggolan wrote: fopen(DRBS.DBF) [function.fopen]: failed to open stream: No such file or directory
BINGO!
So what's the full path to:
- dbf_class.php
- DRBS.DBF
- The file that creates the instance of the dbf_class
Also, is the cAsE correct for DRBS.DBF?
Is it drbs.dbf perhaps?
|
|
|
|
|
hi
Please I try to retrieve data from web services (soap) and must pass an ID in cookie http header I tried with java code (eclipse) but I can not I tried also with other tools tjrs but its not happening ...
I am beginner I really need a helping hand to find the error and the tool to be used
Thank you in advance
My prob is in the URL: I can not add it and how to add the "sid"on url (sid: is the username (cookie))
|
|
|
|
|
|
|
Just a suggestion - please don't post so much of code here. you might be working for some employer and if he finds out that the code is being leaked on public forums you might get in trouble.
Post just the stuff that is causing the problem. always be discreet while giving code. make sure you don't violate the employes NDA in any way. we don't want you to get in trouble.
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|
|
thx for advice i delet the code
|
|
|
|
|
Hi,
I want to know how can I format a number like this:
year = 2012
month = 7
it should be:
year = 2012
month = 07
then bill_code = 201207 (as int)
|
|
|
|
|
int bill_code = 100 * year + month;
|
|
|
|
|
Hello Guys,
I, Vadim Segal, is here to discuss my query regarding website Contact Us Page.I have a website developed in PHP. The contact us page of the website display the contact detail , but now I want to modify this page and want to add the contact us form to this page. So that , whenever the visitor enter their query, it can directly come to mail address. Please help me with your valuable advice.
Thanks
Vadim
|
|
|
|
|
I wrote an article on creating a .Net REST service.
.NET REST service[^]
I hoped to re-write the REST aspects utilizing a .Net restful service open source project. I'm avoiding WCF, as it is counter-REST (light-weight/simple). I am thinking of something fluent, spring-like, convention over configuration. It needs to be robust, handle all the verbs, async, file transfers and auth/security.
I can't find anything at all. Anyone have any leads for a .Net library or Java libraries that could be ported? There may also be an opportunity to start an open source project.
Thanks,
-Bruce
-bruce
|
|
|
|
|
Hello,
i want to make an attendance system in asp.net i have made two tables
1.attence_record (in which i have attendance record like record_id, date, class, subject)
2.raw_att (in which i have particular date and subject attendance)
record_id is foreign key in rwa_att.
now i want to create a grid view control to get the status of particular student.
i also need a dropdown for filling status. that is the main problem.
|
|
|
|
|
Ajit0010 wrote: i want to make an attendance system in asp.net
Ok. Good idea.
Ajit0010 wrote: 1.attence_record (in which i have attendance record like record_id, date, class, subject)
2.raw_att (in which i have particular date and subject attendance)
record_id is foreign key in rwa_att.
Create two tables with column as per need
Ajit0010 wrote: now i want to create a grid view control to get the status of particular student.
Use ADO.NET to get data from DB and use it for display in grid
Ajit0010 wrote: i also need a dropdown for filling status.
Assuming, you meant dropdown in grid, this should give you some idea:
MSDN: Walkthrough: Displaying a Drop-Down List While Editing in the GridView Web Server Control[^]
Now, try first what you want to do! You may find that it's not that hard. Formulate what was done by you that looks like an issue/not working.
|
|
|
|
|
Hi,
How can I redirect user based on thier compnuter language so if the page is English then redirect to www.mydomain.com/en otherwise stay on root www.mydomain.com?
|
|
|
|
|
You could try and base it on the 'Accept-Language' header that the browser sends to the website. This contains a list of preferred languages. See official W3 specifications[^] for more on how to use this header.
But make sure to always have an option for users to change the default language on the site, or you might get angry users that don't want english even though their computer indicates it is the preferred language.
|
|
|
|
|
How to make tab using php in CodeIgniter framework?
|
|
|
|
|
Please, I need help and assistant on how to go about to create and devlop a simple website with easy navigation through the pages
|
|
|
|
|
|
I want to build a webpage or site that will show about our training and camping and all the activities that happened during the camping, but don't know how to go about it
|
|
|
|
|
Okezie Victor wrote: don't know how to go about it
Then you need to spend some time learning. Follow the link I provided and start with some of the tutorials, read some of the CodeProject Articles[^], or even try using Google to search for ready made customizable solutions.
|
|
|
|
|
Hi ,
We have created a new Webservice , in this service we are using exterenal webservice in this webservice wsdl namespce tage () is empty and getting this error : "Schema item 'import' from namespace ''. The namespace attribute cannot have empty string as its value.could you please assit me
Thanks,
Vinay
Vinay
|
|
|
|
|
|
Hi,
I am just beginning with url rewriting. I want some guide please..
I just wanted to know how can I make:
www.mydomain.com/contact.aspx
to show like this:
www.mydomain.com/contact
Thanks
|
|
|
|