
//store the path for displaying the image
$ads_img = $_FILES["image_upload"]["name"];
$ads_img = addslashes($ads_img);
$filename = $_FILES["image_upload"]["name"];
/*insert query*/
$bid = $_POST['brand_id'];
$bshotid = $_POST['brandshots_id'];
$tagS = $filename;
$tagI = $filename;
$EB = $_POST['entered_by'];
$DE = date('Y-m-d / H:i:s');
$MB = $_POST['entered_by'];
$DM = date('Y-m-d / H:i:s');
$sql =$modx->query("INSERT INTO mod_brandshots (system_brandshots_id, system_brand_id, tagshots, tagimages, entered_by, date_entered, modified_by, date_modified)VALUES
('$bid','$bshotid','$tagS','$tagI','$EB','$DE','$MB','$DM')");
if(isset($_POST['update_upload'])){
(update query here)
}$object->set('fieldName', $value);
/* more of the same */
$object->save();Notice: Undefined variable: object in C:\tfv\public_html\core\cache\includes\elements\modsnippet\40.include.cache.php on line 104 Fatal error: Call to a member function set() on a non-object in C:\tfv\public_html\core\cache\includes\elements\modsnippet\40.include.cache.php on line 104
If so, all you need is to get the object you want to update with $modx->getObject() and then do something like this:
if ($object = $modx->getObject('yourObjectClass',$yourObjectID)){
$object->set('fieldName', $value);
/* more of the same */
$object->save();
}
else{
//error handling, couldn't get the object
}
if ($object = $modx->getObject('Brandshots',$bid)){
$object->set('system_brandshots_id', $bshotid);
$object->set('tagshots', $tagS);
$object->set('tagimages', $tagI);
$object->set('entered_by', $EB);
$object->set('date_entered', $DE);
$object->set('modified_by', $MB);
$object->set('date_modified', $DM);
$object->save();
}
else{
echo'error';
}
$object = $modx->getObject('Brandshots', $id);
$object = $modx->getObject('Brandshors', array('name' => 'SomeObjectName')); // change 'name' to the actual field name