motanelu. Posted October 14, 2008 Share Posted October 14, 2008 Hello i'm new to php and OOP but i want to learn like everyone else. i started to make my first script but i run on some trobles.. and maybe u can guys can help me if u have time and you want i'm trying to make on oop members system but i have an error and i don't know how to fix it . Notice: Use of undefined constant mysql_affected_rows - assumed 'mysql_affected_rows' in C:\webserver\public_html\classes\process_users.class.php on line 55 lol my class: class Process { var $subuser; var $subpass; function Process() { global $usersystem, $session, $db; if (isset($_POST['logon']) == true) { $this->Logon($_POST['username'], $_POST['password']); } } function Logon($subuser, $subpass) { global $usersystem, $session, $db; if (isset($_POST['username']) && isset($_POST['password'])) { $subuser = $_POST['username']; $subpass = $_POST['password']; if (!$subuser || strlen($subuser = trim($subuser)) == 0) { $errors['username'] = 'Username Incorect'; } else { if (!eregi("^([0-9a-z])*$", $subuser)) { $errors['username'] = 'Username not alphanumeric'; } } if (!$subpass) { $errors['password'] = 'Password Incorect'; } else { $this->DoLogin($subuser, $subpass); } } } function DoLogin($subuser, $subpass) { global $db; $this->username = $subuser; $this->password = $subpass; var_dump($subuser, $subpass); $sql = sprintf("SELECT * FROM xWeb_members WHERE username = '%s' AND password = '%s'", $this->clean($this->username), $this->clean($this->password)); $res = $db->Query($sql); if (mysql_affected_rows != 1) { ---> this is line 55 echo 'lol'; return false; } else { $row = $db->FetchAssoc($res); $this->email = $row['email']; session_regenerate_id(); $_SESSION['LoggedIn'] = true; $_SESSION['username'] = $this->username; $_SESSION['email'] = $this->email; } return true; } function clean($str) { if (get_magic_quotes_gpc()) { $str = stripslashes($str); } $str = mysql_real_escape_string($str); return $str; } } $process = new Process(); ?> my mysql class that i'm using it: <? class MySQL { function Connect($host, $name, $pass, $dba) { $connection = mysql_connect("$host", "$name", "$pass"); mysql_select_db("$dba", $connection); if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } } function Close() { mysql_close($this->connection); } function Query($sql) { $query = mysql_query($sql) or die(mysql_error()); return $query; } function FetchRow($query) { $rows = mysql_fetch_row($query); return $rows; } function FetchArray($query) { $array = mysql_fetch_array($query); return $array; } function FetchNum($query) { $num = mysql_num_rows($query); return $num; } function Affected() { return mysql_affected_rows($this->Connect); } } ?> i repeat this is my first oop script :-s i don't think it's the best.. but.. i think it's a start.. so if you kind please help me Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/ Share on other sites More sharing options...
DarkWater Posted October 14, 2008 Share Posted October 14, 2008 You forgot the () on the end of mysql_affected_row(). Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/#findComment-665552 Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 Looks like someone has been borrowing code from vBulletins database class Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/#findComment-665555 Share on other sites More sharing options...
DarkWater Posted October 14, 2008 Share Posted October 14, 2008 Looks like someone has been borrowing code from vBulletins database class Is that really vBulletin's database class? That's horrid. EDIT: I mean the code. Like, it's really bad. Why would vBulletin do that? *sob* Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/#findComment-665556 Share on other sites More sharing options...
CroNiX Posted October 14, 2008 Share Posted October 14, 2008 Just this part looked familiar: $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/#findComment-665565 Share on other sites More sharing options...
motanelu. Posted October 15, 2008 Author Share Posted October 15, 2008 Just this part looked familiar: $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); that function a friend gave it to me dunno from where it has Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/#findComment-666017 Share on other sites More sharing options...
motanelu. Posted October 15, 2008 Author Share Posted October 15, 2008 now it gives me this error Fatal error: Call to undefined method MySQL::FetchAssoc() in C:\webserver\public_html\classes\process_users.class.php on line 59 this is my fetch function function FetchAssoc($query) { $fetch = mysql_fetch_array($query); return $fetch; } Quote Link to comment https://forums.phpfreaks.com/topic/128438-my-first-oop/#findComment-666090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.