Welcome to WebmasterWorld Guest from 54.166.114.43

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Fatal Error: Call to a member function MoveNext() on a non-object

   
12:05 am on Mar 16, 2010 (gmt 0)

5+ Year Member



Can anyone help me out and take a look at this code to see if I'm missing something? It's a piece of a larger script pulling XML data from another server and put it in the DB on my site. But randomly while the script is running I'll get that error listed in the title. It's the random part that really gets me because it happens on all different rows(when I try restarts), so even if a row failed 1 time it can work fine another time. Here's the code.

$duplicateRemoved = false;
$dup_record = null;
while (!$recordSet->EOF) {
$dup_record = $recordSet->fields['listingsdb_id'];
$dupWhere = " WHERE listingsdb_id = '" . $dup_record . "'";
$BATCH_RESULT->addDuplicatedItem();
if ($EXTRACT_CONTEXT->refresh) {
if (!$EXTRACT_CONTEXT->mls_only) {

// retain non-MLS data

$sql = 'SELECT * FROM ' . $TARGET_CONTEXT->data_table . $dupWhere;
$recordSet2 = $conn->Execute($sql);
if ($recordSet2 === false) {
//$BATCH_RESULT->addError("user data bypass ERROR " . $sql);
} else {
if ($recordSet2 != null) {
while (!$recordSet2->EOF) {
$temp = $recordSet2->fields['listingsdbelements_field_name'];
if (!array_key_exists($temp, $data)) {
print('<br/>Saving value for field [' . $temp . '] from record ' . $dup_record . '<br/>');
$userSuppliedData[$temp] = $recordSet2->fields['listingsdbelements_field_value'];
}
$recordSet2->MoveNext();
}
}
}
}

// delete all data for this listing

$sql = 'DELETE FROM ' . $TARGET_CONTEXT->data_table . $dupWhere;
$recordSet2 = $conn->Execute($sql);
if ($recordSet2 === false) {
$BATCH_RESULT->addError('delete data ERROR ' . $sql);
}

if (!$EXTRACT_CONTEXT->mls_only) {

// delete only MLS images for this listing

$imagesPrior = 0;
$sql = 'select * FROM ' . $TARGET_CONTEXT->image_table . $dupWhere;
$recordSet2 = $conn->Execute($sql);
if ($recordSet2 === false) {
$BATCH_RESULT->addError('select count from image ERROR ' . $sql);
}
if ($recordSet2 != null) {
$imagesPrior = $recordSet2->NumRows();
}
$imagesDeleted = 0;
for ($i = 0; $i < ($EXTRACT_CONTEXT->max_images + 1); ++$i) {
$image_name = $dup_record . '_' . $i . '.jpg';
$image_path = $TARGET_CONTEXT->image_upload_path . '/' . $image_name;
if (file_exists($image_path)) {
unlink($image_path);
$thumb_path = $TARGET_CONTEXT->image_upload_path . '/' .
EXP_THUMB_PREFIX . $image_name;
if (file_exists($thumb_path)) {
unlink($thumb_path);
}
$imagesDeleted++;
$sql = 'DELETE FROM ' . $TARGET_CONTEXT->image_table . $dupWhere . " AND listingsimages_file_name = '" . $image_name . "'";
$recordSet2 = $conn->Execute($sql);
if ($recordSet2 === false) {
$BATCH_RESULT->addError('delete from image ERROR ' . $sql);
}
}
}
$userSuppliedImages = $imagesPrior - $imagesDeleted;
} else {

// delete all images for this listing

$sql = 'DELETE FROM ' . $TARGET_CONTEXT->image_table . $dupWhere;
$recordSet2 = $conn->Execute($sql);
if ($recordSet2 === false) {
$BATCH_RESULT->addError('delete from image ERROR ' . $sql);
}
for ($i = 0; $i < ($EXTRACT_CONTEXT->max_images + 1); ++$i) {
$image_name = $dup_record . '_' . $i . '.jpg';
$image_path = $TARGET_CONTEXT->image_upload_path . '/' . $image_name;
if (file_exists($image_path)) {
unlink($image_path);
$thumb_path = $TARGET_CONTEXT->image_upload_path . '/' .
EXP_THUMB_PREFIX . $image_name;
if (file_exists($thumb_path)) {
unlink($thumb_path);
}
}
}
}
$duplicateRemoved = true;
} else {
$clearToInsert = false;
}
$recordSet->MoveNext();
}
12:32 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



since MoveNext is being performed on your recordsets then look at them, maybe you have an empoty node or bad char in the file. I don't think they're random, you just haven't seen the pattern yet, have it die and dump the data or position in the file and look at that.
12:41 pm on Mar 16, 2010 (gmt 0)

5+ Year Member



I think I've been trying that because I added in just before $recordSet->MoveNext() a var_dump($recordSet) and it dumps the info great everytime, until the error on that line it returns a bool(false). Is there another function I can use to give me more info than a var_dump?
1:57 pm on Mar 16, 2010 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I usually echo anything that I can use to search the file, then find the problem point in the actual data, look at them, mark them, then run it a few times and see all the points where the error happens and see if they're the same.

you need to profile what exactly is happening and if you are only outputting the variables from php that is only one side of it.

look at the real data before, after and mid processing if you can

nothing is random
3:40 pm on Mar 16, 2010 (gmt 0)

5+ Year Member



thanks I've started echoing above and it gets even odder(at least to me) In the beginning of the loop:

$dup_record = $recordSet->fields['listingsdb_id'];
I added echo $dup_record;
$dupWhere = " WHERE listingsdb_id = '" . $dup_record . "'";
and echo $dupWhere;

It counts up 1 then 2, 3. Then just stops and doesn't return a value and I get the original error, even though when I check in the db the next value is there. Sorry just talking outloud here trying to wrap my head around this.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month