Forums

Update query problem

Tom0 12 Dec, 2008
Hi,

Following quickly on from my last post (AEC,CF and CB), I am having some trouble getting the database to update, Ive tried this code at the top of my form, and in the submit boxes (although surely its simple enough not to really matter where it is??)


<?php

$database = &JFactory::getDBO();

// this works and shows the right thing:
$query = "SELECT parq FROM #__users WHERE id = 84;";
$database->setQuery( $query );
$results = $database->loadObjectList();
echo print_r($results);
echo "<br><br>";

// this works when pasted into phpmyadmin:
$query = "UPDATE #__users SET parq = 1 WHERE id = 84 LIMIT 1;";
$database->setQuery( $query );

// but this shows the same thing again! no change!
$query = "SELECT parq FROM #__users WHERE id = 84;";
$database->setQuery( $query );
$results = $database->loadObjectList();
echo print_r($results);

?>


I have boiled it down to this most simple example and have been searching the forums and copying code all morning!!

Im sure I must be missing something simple? Any help will be massively appreciated!! 😀

Tom
Max_admin 12 Dec, 2008
Hi Tom,

after
$database->setQuery( $query );
you need
$database->query();
for update or insert or delete!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Tom0 12 Dec, 2008
So simple!! schoolboy error...

Thanks for the instant fix!!

Tom
This topic is locked and no more replies can be posted.