Welcome Guest, Not a member yet? Register   Sign In
Error with AR and MS SQL.
#1

[eluser]Zandy[/eluser]
Hi! codeigniters''.. :-)

this is a code of my main controller...

Code:
<?php
class main extends Controller
{
    function main(){ parent::Controller(); }
    function index()
    {
        $this->load->database();
        $data = array('token' => 'miCodigo');
        $this->db->where('id_usuario', 5);
        $this->db->update("[TBL_USUARIO]", $data);
    }
}
?>

but not work :down:.
This is the mistake..

Quote:A Database Error Occurred
Error Number:
UPDATE [TBL_USUARIO] SET "token" = 'miCodigo' WHERE "id_usuario" = 5

What can I do ??

greetings
#2

[eluser]jcopling[/eluser]
You can can look inside system/logs folder and open up the file from today to receive a more friendly error message. If you are still stumped, copy and paste the actual log error here as it will be more helpful.
#3

[eluser]Zandy[/eluser]
my log folder is empty, only index.html file inside. :?.... how to active the log. :?
#4

[eluser]bscott[/eluser]
To get the sql error message displayed, change the mssql_driver.php _error_message() function from:-

function _error_message()
{
// Are errros even supported in MS SQL?
//return ‘’;
}

to

function _error_message()
{
return @mssql_get_last_message();
}

Alternatively cut and paste the displayed sql into ms query analyser or equivalent and run the query there to find the error.
#5

[eluser]jcopling[/eluser]
In your application/config/config.php file make sure that your log_threshold is at least 1, like this:
Code:
$config['log_threshold'] = 1;

Also, make sure that your system/logs folder has write permissions on it.
#6

[eluser]Zandy[/eluser]
Quote:<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>

ERROR - 2008-08-15 10:06:13 --&gt; Severity: Warning --&gt; mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: Unclosed quotation mark before the character string '[TBL_USUARIO] SET &quot;token&quot; = 'miCodigo' WHERE &quot;id_usuario&quot; = 5'. (severity 15) C:\AppServ\www\gen\system\database\drivers\mssql\mssql_driver.php 106
ERROR - 2008-08-15 10:06:13 --&gt; Severity: Warning --&gt; mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: Line 1: Incorrect syntax near '[TBL_USUARIO] SET &quot;token&quot; = 'miCodigo' WHERE &quot;id_usuario&quot; = 5'. (severity 15) C:\AppServ\www\gen\system\database\drivers\mssql\mssql_driver.php 106
ERROR - 2008-08-15 10:06:13 --&gt; Severity: Warning --&gt; mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed C:\AppServ\www\gen\system\database\drivers\mssql\mssql_driver.php 106
ERROR - 2008-08-15 10:06:13 --&gt; Severity: Warning --&gt; mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. (severity 16) C:\AppServ\www\gen\system\database\drivers\mssql\mssql_driver.php 106
ERROR - 2008-08-15 10:06:13 --&gt; Severity: Warning --&gt; mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed C:\AppServ\www\gen\system\database\drivers\mssql\mssql_driver.php 106
ERROR - 2008-08-15 10:06:13 --&gt; Query error:


This is the log that generates ....


thanks to everyone ..
#7

[eluser]Zandy[/eluser]
the query of error is this

Quote:UPDATE ["TBL_USUARIO"] SET "token" = 'miCodigo' WHERE "id_usuario" = 5

I put it in the sql analyzer and error in this [ ], but watching this post.. :long:

?? put or not put ( \[ \] ). ???

uhmm

greetings
#8

[eluser]Zandy[/eluser]
to remove the [], modifying the probe follows function
Code:
function _escape_table($table)
{        
    return $table;
}
the query is absolutely correct, but gives error D..




Theme © iAndrew 2016 - Forum software by © MyBB