Click to See Complete Forum and Search --> : php error, plz help


roeyhaim
October 30th, 2010, 10:50 PM
Hello all,
i am new to php and need help with my code.


<?php
class vars{
function get($filed_name){
$data = $_GET[$filed_name];
if(!$data) return 0;
return $data;
}
}
?>

<?php
$clss = new vars();
header('Content-Type: text/html; charset=utf-8');
define("BaseSite", "http://localhost:3000/");
?>

<?php
if (!$_GET['edit'] & !$_GET['id']) {
?>

<html>
.....
</html>

<?php } else {
if($_GET['edit'] == 1 & $_GET['id'] > 0){
$ID = $vars->get("id");
$update = 1;
?>
<html>
......
</html>

<?php
}
?>when the BOLD line is calling i get an error:
"php call to a member function get() on a non-object......"

someone can help me please?

PeejAvery
October 31st, 2010, 07:05 AM
Please remember to search before posting. This is the most common PHP error. It means you're using a function off an object type variable.

$ID = $vars->get("id");

No where in that script did you create $vars so naturally it cannot be an object.

roeyhaim
October 31st, 2010, 08:33 AM
thank you very much.
i dont know how i didnt notice. :)