php - Joomla using insert into a separate database table -
$option = array(); $option['driver'] = 'mysql'; // database driver name $option['host'] = 'localhost'; // database host name $option['user'] = '*****'; // user database authentication $option['password'] = '********'; // password database authentication $option['database'] = 'teste_dados'; // database name $db = jdatabase::getinstance( $option );
// create new query object.
$query = $db->getquery(true);
/* // insert columns.
$columns = array('id_teste','testes','time');
// insert values.
$values = array(4,'loucura3',date("h:i:s"));
// prepare insert query.
$query->insert($db->quotename('teste1')); $query->columns($db->quotename($columns)); $query->values(implode(',', $values));
or
$query="insert teste1('id_teste','testes','time') values (4,'loucura3','".date("h:i:s")."')";
// set query using our newly populated query object , execute it.
$db->setquery($query); $db->execute();
both options gives following error message:
an error has occurred while processing request.
you may not able visit page because of:
an out-of-date bookmark/favourite mistyped address search engine has out-of-date listing site have no access page
go home page
home page
if difficulties persist, please contact system administrator of site , report error below.
0 sql=insert teste1('id_teste','testes','time') values (4,'loucura3','05:11:00')
i`ve seen similar problems , fixes , none of them workd me ideas?.
try testing sql script in mysql workbench or phpmyadmin. use backticks instead of single quotes around columns
Comments
Post a Comment