PHP / MySql Function call problem
Posted: Tue Sep 23, 2008 7:40 am
I wrote a class Database, defining the methods connect(), close($con), select_gen($query,$con), update_gen($query,$con).
The method select_gen is just calling the mysql_query method:
Now, in one of my php pages, its working if i call the mysql_query method, but not if I call the method for my object database...
Why? I dont understand... im just passing a variable in parameter to do the exact same treatment... please help me!
The method select_gen is just calling the mysql_query method:
Code: Select all
function select_gen($req,$con){
$reponse=mysql_query($req,$con)
or die("Query Error");
return $response;
}
Code: Select all
//Creating the object and the connection
$db = new Database();
$con = $db->connect();
//formatting the query
$string = mysql_real_escape_string($string);
$sql = "SELECT * FROM sg_content as t1 WHERE t1.content_name LIKE '%".$string."%' OR t1.content_des LIKE '%".$string."%' ORDER BY t1.content_id";
[b]/* This works! */[/b]
$result = mysql_query($sql,$con);
[b]/* This doesnt throw an error but return an empty result */[/b]
$result = $db->select_gen($sql,$con);
$db->close($con);
Why? I dont understand... im just passing a variable in parameter to do the exact same treatment... please help me!