-1

I don't understand who to use class in other file.

db.php is my Mysql Class and i want to use my mysql class in other file :

<?
require ("db.php");

$sql = new MySQL('vinizos_beta', 'root', 'root', 'localhost');


function show_all(){

$query = 'SELECT * FROM domaines';
$result = $sql->executeSQL($query);
$lastError = $sql->lastError;
print_r($result);
}
?>

But i have this error, and i don't know why ?

Undefined variable: sql

1 Answers1

1

You must pass $sql as a parameter to show_all():

function show_all($sql){
Michael Wagner
  • 1,008
  • 8
  • 20