mysql_query returning boolean instead of mysql ressource


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I seem to have a weird issue with the php command mysql_query. I pass 2 arguments the query in a string format (SQL is working properly) and a database ressource which is also good. The problem is that even with good parameters, the mysql_query returns me bogus data

Did you know?Explore Trending and Topic pages for more stories like this.
exact code that cause problem
Code: public function execute($query){
$result = mysql_query($query, $this -> ressource);
return $result;
} // execute

the full database object code
Code: class DBconnexion{

private $host; // database url/host
private $user; // database login name
private $pass; // database login password
private $db; // database name
private $ressource; // mysql ressource for database

public function DBconnexion($db_host, $db_user, $db_pass, $db_name){
$this -> host = $db_host;
$this -> user = $db_user;
$this -> pass = $db_pass;
$this -> db = $db_name;

// connect to database
$cnDB = mysql_connect($this -> host, $this -> user, $this -> pass);
mysql_select_db($this -> db, $cnDB);

// store database ressource in database object
$this -> ressource = $cnDB;
} // DBconnexion (constructor)

// getter for database ressource
public function get(){
return $this -> ressource;
} // get_connexion

public function execute($query){
$result = mysql_query($query, $this -> ressource);
return $result;
} // execute

public function number($sqlRessource){
$result = mysql_num_rows($sqlRessource);
return $result;
} // number

public function row($sqlRessource){
$result = mysql_fetch_row($sqlRessource);
return $result;
} // row

} // DBconnexion
No comments posted yet

Your Answer:

Login to answer
311 Like 37 Dislike
Previous forums Next forums
Other forums

function to return url
Hi,

Can you guys help me giving a function that takes all the contents in a particular field

SQL Injection
In my attempts to protect my database from mySQL injection I have created another problem for myself

natcasesort works on one server but not on another
Hi

I have a problem that I was hoping that someone can help me with.

I'm trying to use

how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy

mysql VARCHAR acting like INT
Hi, All.

I have a table that contains a varchar(10) column named weird_field. In this column

Displaying data from database into a 2 dimensional table
Good day!

I'm a beginner in PHP and I'm not expecting a full coding for this qestion. I'm jus

Date Format
Hi there,

I have a date format like this right now:
Sat, 17 Oct 2009 17:04:00

I ne

Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doi

file_put_contents and createimagefromjpeg
All,
I do somethings and then I have the following code:
file_put_contents('./test/'.$filename

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash