Update another table on form submit

PHP Setting

Update on both

Execute code on After Data Stored and before calculations

Code

Code:
<?php
$connect = mysql_connect('localhost','emscompl_paramed','Paramedic!283') or die(mysql_error());
        $selectdb = mysql_select_db('emscompl_ccems_joomla',$connect);
       
        $sql = "SELECT * FROM vehicle_check
        WHERE id = {vehicle_check___id}";
        $getsql = mysql_query($sql);
        $fetchsql = mysql_fetch_array($getsql);
       
       
        $squad = $fetchsql['squad_number'];
        $narcotic = $fetchsql['narcotic_box_number'];
        $narcoticseal= $fetchsql['narcotic_box_seal'];
        $narcoticsealcolor= $fetchsql['narcotic_box_seal_color'];
        $morphine = $fetchsql['morphine'];
        $ativan = $fetchsql['ativan'];
        $fentanyl=$fetchsql['fentanyl'];
        $iobag = $fetchsql['io_gun_bag_number'];
        $iobagseal = $fetchsql['io_gun_bag_seal'];
       
        $update = "UPDATE units SET narcotic_box_number=$narcotic, narcotic_box_seal=$narcoticseal, narcotic_box_seal_color=$narcoticsealcolor, morphine=$morphine, ativan=$ativan, fentanyl=$fentanyl, io_gun_bag_number=$iobag. io_gun_bag_seal=$iobagseal
        WHERE squad_number = $squad";
       
        mysql_query($update);
       
?>
 
hi Josh

I think you missed adding a question?

At a guess I'd say your update doesn't happen?
In that case you want to quote the values you are setting.

PHP:
$db = JFactory::getDbo();
 
// then quote each value you want to update.
$squad = $db->quote($fetchsql['squad_number']);
 
Rob your right looks like I forgot to add the question... Sorry about that I will try this out tomorrow and see if I can get it to work
 
Ok I have went back and completly revamped the code however it is still not working. Also it appears my place holder have stopped working????

Code:
<?php
$db = JFactory::getDbo();
$sql = $db->getQuery(true);
     
        $sql->select(array('*'));
        $sql->from('vehicle_check');
        $sql->where('id = '{vehicle_check___id}'');
       
        $db->setQuery($sql);
       
        $fetchsql = $db->loadObjectList();
     
     
        $squad = $db->quote($fetchsql['squad_number']);
        $unit = $db->quote($fetchsql['unit_number']);
        $narcotic = $db->quote($fetchsql['narcotic_box_number']);
        $narcoticseal= $db->quote($fetchsql['narcotic_box_seal']);
        $narcoticsealcolor= $db->quote($fetchsql['narcotic_box_seal_color']);
        $morphine = $db->quote($fetchsql['morphine']);
        $ativan = $db->quote($fetchsql['ativan']);
        $fentanyl= $db->quote($fetchsql['fentanyl']);
        $iobag = $db->quote($fetchsql['io_gun_bag_number']);
        $iobagseal = $db->quote($fetchsql['io_gun_bag_seal']);
       
     
      $query= $db->getQuery(true);
     
              $query->update('units');
            $query->set('narcotic_box_number='.$narcotic,'narcotic_box_seal='.$narcoticseal,'narcotic_box_seal_color='.$narcoticsealcolor,'morphine='.$morphine, 'ativan='.$ativan,'fentanyl='.$fentanyl, 'io_gun_bag_number='. $iobag,'io_gun_bag_seal='.$iobagseal);
            $query->where('squad_number ='.$squad.'and unit_number ='.$unit);
           
            $db->setQuery($query);
           
      //execute db object
try {
// Execute the query in Joomla 3.0.
$result = $db->execute();
} catch (Exception $e) {
//print the errors
print_r($e);
}
 
Is this running as a file, or inline? i.e. did you paste the code into the PHP box, or put it in a file you then select from the dropdown?

-- hugh
 
add an
PHP:
exit;
at the end of the file.
Ensure you're site, in its global configuration, is set to error reporting = maxium
Then re-test

Report back what you see on the page.

thx
-Rob
 
you wouldnt see the query in the debug out put as the query would only be run on submission, not on page load.

I couldn't fill in the form, get lots of error messages on the ajax validation, perhaps try disabling the addfullajax system plugin?:

Property _template_tags does not exist

Call stack
# Function Location
1 JSite->render() /home/emscompl/public_html/ccems/index.php:58
2 JApplicationBase->triggerEvent() /home/emscompl/public_html/ccems/includes/application.php:283
3 JEventDispatcher->trigger() /home/emscompl/public_html/ccems/libraries/joomla/application/base.php:106
4 JEvent->update() /home/emscompl/public_html/ccems/libraries/joomla/event/dispatcher.php:161
5 call_user_func_array() /home/emscompl/public_html/ccems/libraries/joomla/event/event.php:71
6 plgSystemAddFullajax->onBeforeRender()
7 plgSystemAddFullajax->getValue() /home/emscompl/public_html/ccems/plugins/system/addfullajax/addfullajax.php:200
8 ReflectionClass->getProperty()
/home/emscompl/public_html/ccems/plugins/system/addfullajax/addfullajax.php:612
 
i cant submit the form, its vailidating not empty on 'Paramedic/EMT Completing Form' when there are no possible options to select
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top