Jump to content

Mysqli query returning failure, but wont give an error message.


Recommended Posts

Hi Guys,

 

I have a problem with running a mysql query using the mysqli api;

 

I'm running PHP version 5.1.6 on linux  with Apache 2.

 

When I try execute a query on my server that works on my local machine the result set is false (failure) but mysqli_error($link) returns nothing at all. I expect it to come back with a result set or to provide me with an error why it failed.

 

I have ensured I have an open and valid connection at the time of the query, I have also tried catching mysqli_sql_exception to no avail. No error seems to propegate, but the result of the query is false (failure according to the docs). Any help would be appreciated.

 

My local machine is running php 5.2.9, and can successfully run the query through an ssh tunnel to the same database

 

The wierd thing is that if I use the old mysql api the inverse happens, the query works on the server that is on lan with the database, and my local machine fails to connect through the ssh tunnel.

 

The code that runs the query is as follows, and I make sure the connection is open before hand:

 

	try {
	    $this->result = mysqli_query($this->dblink,$sql); 
	}catch (mysqli_sql_exception $e) {
	    print "Error Code <br>".$e->getCode();
	    print "Error Message <br>".$e->getMessage();
	    print "Strack Trace <br>".nl2br($e->getTraceAsString());
	}

	if (!$this->result) {
		print("Error running query: ($sql) Error: (".mysqli_error($this->dblink).")");
	}

	return $this->result;

 

I suspect its somthing to do with the server configuration as the code works fine locally, any ideas would be appreciated.

 

Cheers,

 

ShCiPwA

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.