Execute INSERT SQL query on Joomla - Joomla! Forum - community, help and support


anyone can see if syntax error quoted below? couldn't figure out what's wrong causing data storing database fails.
p/s: im using joomla 2.5.8

$db =& jfactory::getdbo();
$lastinsertid = $db->insertid();

$color_ids = $_post['color_id'];

foreach($color_ids $color) {

$sqlstat = "insert #__file_color_map (colour_id, files_id) values ( $color, $lastinsertid )";
echo $sqlstat;
$db->setquery($sqlstat);

}


when echo-ed $sqlstat shows :
insert #__file_color_map (colour_id, files_id) values ( 3, 32 )
insert #__file_color_map (colour_id, files_id) values ( 4, 32 )

it seems no problem sql query part... can help?

vsoy wrote:anyone can see if syntax error quoted below? couldn't figure out what's wrong causing data storing database fails.
p/s: im using joomla 2.5.8

$db =& jfactory::getdbo();
$lastinsertid = $db->insertid();

$color_ids = $_post['color_id'];

foreach($color_ids $color) {

$sqlstat = "insert #__file_color_map (colour_id, files_id) values ( $color, $lastinsertid )";
echo $sqlstat;
$db->setquery($sqlstat);

}


when echo-ed $sqlstat shows :
insert #__file_color_map (colour_id, files_id) values ( 3, 32 )
insert #__file_color_map (colour_id, files_id) values ( 4, 32 )

it seems no problem sql query part... can help?


you must add following line after $db->setquery($sqlstat);

code: select all

$db->query();





Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

PProHeadless.exe has stopped working error when opening projects in Adobe Media Encoder CS6

Preconditions Failed. - Joomla! Forum - community, help and support