homepage Welcome to WebmasterWorld Guest from 54.204.77.26
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




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

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();
}

 

jatar_k




msg:4098701
 12:32 pm on Mar 16, 2010 (gmt 0)

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.

Ahkamden




msg:4098709
 12:41 pm on Mar 16, 2010 (gmt 0)

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?

jatar_k




msg:4098758
 1:57 pm on Mar 16, 2010 (gmt 0)

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

Ahkamden




msg:4098843
 3:40 pm on Mar 16, 2010 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved