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

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

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

mail() says sent but no email received
My code is quite simple:

Code: <?php
$to = "Ty44ler@yahoo.com";
$subje

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

Creating a function
Basically i wanna put all this code in a seperate file

Code: <?php

SHOW TABLES Help
Hi all

I have the following

Code: [Select]<?php
$sql = "SHOW TABLES&quo

array_combine() error
getting an "Warning: array_combine() [function.array-combine]: Both parameters should have an e

Need understanding of this bit of code
Code: <?php
// WHERE clause filters
$arrSQLFilters = array();

//

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

import table with dependency
Hi

What is the best way to import table back which has dependency?

SQL> cre

same querie, or a new one??
Hi guys,

I'm still working on this drop down list. I've got the actual drop down list to wor

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