top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Error to insert in firebird when using PHP

+1 vote
160 views

I am trying to execute the following but he does not execute me well. Which will be able to be the problem?

$sql = "insert into scele (codigo, nombre) values (?, ?)";
$param = "1, Test1";

$tr = ibase_trans(IBASE_WRITE,$this->cn);
$qr = ibase_prepare($tr,$param);
$this->rs = ibase_execute($sql,$param);
if ($this->rs){
 //Evaluate this condition, but he does not enter here 
}
posted Nov 5, 2013 by Sonu Jindal

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Do you commit your transaction?
Yes

The complete function is:

public function actualizar($sql,$param){
 if ($this->cn){

//for example:
$sql = "insert into scele (codigo, nombre) values (?, ?)";
$param = "1, Test1";

 $tr = ibase_trans(IBASE_WRITE,$this->cn);
 $qr = ibase_prepare($tr,$param);
 $this->rs = ibase_execute($sql,$param);
 if ($this->rs){

 //Evaluate this condition, but he does not enter here

 ibase_commit($tr);
 } else {
 ibase_rollback($tr);
 return array('tipo'=>false,'texto'=>'Error de ejecusin: '
.ibase_errmsg());
 }
 ibase_free_query($qr);
 return array('tipo'=>true,'texto'=>'');
 } else {
 return array('tipo'=>false,'texto'=>'Error de conexin: '
.ibase_errmsg());
 }
}

1 Answer

+1 vote

In the documentation it says that if the query raises an error, returns *FALSE*. You should start calling ibase_errmsg to track where the error is.

answer Nov 5, 2013 by anonymous
$sql = "insert into scele (codigo, nombre) values (?, ?)";
    $param = "1, Test1";
    
    $tr = ibase_trans(IBASE_WRITE,$this->cn);
    $qr = ibase_prepare($tr,$param);
    echo ibase_errmsg() ." ";

Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 1 2

But I do not understand as it can be the error.
Sorry I have no experience with firebird commands.

Just read through the official documentation. If I am to take a blind guess I would point to ibaseprepare($tr,$param); and would say that the variable $param does not belong there but rather in ibaseexecute. What I would try is something like this:

$sql = "insert into scele (codigo, nombre) values (?, ?)";
$param = "1, Test1";

$tr = ibasetrans(IBASEWRITE,$this->cn);
$qr = ibaseprepare($this->cn, $tr, $sql);
$this->rs = ibaseexecute($qr,$param);
.......

If this doesn't work remove the parameters and put static values and see if that works...etc... you have to really debug line by line.
Similar Questions
0 votes

I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3.

An earlier version of this application works. The current version causes a 500 Internal Server Error. There is no entry in PHP's (fully active) error log. I cannot decipher Abyss's logging, so I cannot determine if a clue was reported by Abyss or not.

The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 (Apache module), Apache 2.2).

What I would like to have is a method of getting PHP to report in some undeniable manner, short of total system failure, what it doesn't like about whatever killed it.

0 votes

I have created a form which take in values like
NAME
ADDRESS
EMAIL ID
PHOTO
PHONE NUMBER

i want to add these values into database, but i am having a problem in inserting the Image (photo).

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...