Alex-Grim Posted December 15, 2007 Share Posted December 15, 2007 This was just an included script, but i changed it to be oo, and now it's broken. If you take out all the code between the class definitaion, it doesn't stop page execution, but i've tried taking out sections of the code, and no matter what section i remove, it's not allowing the page to execute, so i don't know what it is, i can't see any errors. Here it is: <?php class UserVars{ $uagent = $_SERVER['HTTP_USER_AGENT']; function time(){ date_default_timezone_set('UTC'); return date('Y-m-d H-i-s'); } function agent(){ return $uagent; } function browser(){ if (ereg("MSIE",$uagent)) { $browser = "IE"; } elseif (ereg( "Opera",$uagent)) { $browser = "Opera"; } elseif(ereg("Firefox",$uagent)) { $browser = "Firefox"; } elseif(ereg("Safari",$uagent)) { $browser = "Safari"; } else { $browser= "other"; } return $browser; } function os(){ if (ereg("Win",$uagent)) { $os="Win"; } else if (ereg("Mac",$uagent)) { $os="Mac"; } else if (ereg("Linux",$uagent)) { $os="Linux"; } else if (ereg("Unix",$uagent)) { $os="Unix"; } else { $os="Other"; } return $os; } funtion dist(){ if (ereg("Fedora",$uagent)) { $distro="Fedora"; } else if (ereg("Ubuntu",$uagent)) { $distro="Ubuntu"; } else if (ereg("Debian",$uagent)) { $distro="Debian"; } else if (ereg("FreeBSD",$uagent)) { $distro="FreeBSD"; } else if(ereg("NT 4.0",$uagent)) { $distro="NT"; } else if (ereg("NT 5.0",$uagent)) { $distro="2000"; } else if (ereg("NT 5.1",$uagent)) { $distro="XP"; } else if (ereg("NT 5.2",$uagent)) { $distro="XP"; }else if (ereg("NT 6.0",$uagent)) { $distro="Vista"; } else { $distro="Other"; } return $distro; } function ip(){ return $_SERVER['REMOTE_ADDR']; } function ip2(){ if ($ip2 = getenv('HTTP_CLIENT_IP')) {} elseif ($ip2 = getenv('HTTP_X_FORWARDED_FOR')) {} elseif ($ip2 = getenv('HTTP_X_FORWARDED')) {} elseif ($ip2 = getenv('HTTP_FORWARDED_FOR')) {} elseif ($ip2 = getenv('HTTP_FORWARDED')) {} else { $ip2 = "0"; } return $ip2; } } ?> Thanx Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 Where is the code that invokes this object and actually uses it? Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 <?php include_once("variables.php"); include_once("../classes/MySql.php"); //$uvar = new UserVars(); $db = new MySql(); $con = $db->C(); $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; $uri = str_replace("http://","",$_POST['uri']); //echo $name . $br; //echo $phone . $br; //echo $email . $br; //echo $comment . $br; //echo $time . $br; //echo $ip . $br; //echo $ip2 . $br; //echo $uvar->browser . $br; //echo $uvar->agent . $br; //echo $uvar->os . $br; //echo $uvar->dist . $br; echo $uri . $br; //$q = $db->Q("Insert into Comments (name,phone,email,comment,uri,commentdate,ipaddy,ipforward,useragent,browser,distro,platform)values('$name','$phone','$email','$comment','$uri','$uvar->time','$uvar->ip','$uvar->ip2','$uvar->agent','$uvar->browser','$uvar->dist','$uvar->os')"); ?> Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 I assume it's the stuff that is commented out? Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 Yes, as you can see, i'm calling the class file, but i'm not even using it yet, and it's still killing the page. Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 What happens if you leave everything commented out except this line: //$uvar = new UserVars(); does just instantiating the object cause the page to bomb? Do you get a specific error? Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 What file is your class stored in? Are you even including it? Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 Simply calling the page to be included is where it's being stopped. I have commented out where i tired to instantiate it and use it, to see if merely including it would kill the page, and as you can see, it does, so the error must be in the class file... Even THIS kills it: <?php include_once("variables.php"); ?> ===Edit=== And YES, they're in the same directory Quote Link to comment Share on other sites More sharing options...
trq Posted December 15, 2007 Share Posted December 15, 2007 Your class is full of methods, not properties. Methods need braces. eg; <?php $uvar = new UserVars; $uvar->ip(); ?> Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 Thank you, you probably just saved me time after we get this imediate problem fixzed. But at the moment, the problem is in the class file. I'm sure now, because i deleted all the code in the calling file, except wheere i call the class, and it still dies. Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 Try this <?php class UserVars{ var $uagent; function UserVars(){ $uagent = $_SERVER['HTTP_USER_AGENT']; } function time(){ date_default_timezone_set('UTC'); return date('Y-m-d H-i-s'); } function agent(){ return $uagent; } function browser(){ if (ereg("MSIE",$uagent)) { $browser = "IE"; } else if (ereg( "Opera",$uagent)) { $browser = "Opera"; } else if(ereg("Firefox",$uagent)) { $browser = "Firefox"; } else if(ereg("Safari",$uagent)) { $browser = "Safari"; } else { $browser= "other"; } return $browser; } function os(){ if (ereg("Win",$uagent)) { $os="Win"; } else if (ereg("Mac",$uagent)) { $os="Mac"; } else if (ereg("Linux",$uagent)) { $os="Linux"; } else if (ereg("Unix",$uagent)) { $os="Unix"; } else { $os="Other"; } return $os; } funtion dist(){ if (ereg("Fedora",$uagent)) { $distro="Fedora"; } else if (ereg("Ubuntu",$uagent)) { $distro="Ubuntu"; } else if (ereg("Debian",$uagent)) { $distro="Debian"; } else if (ereg("FreeBSD",$uagent)) { $distro="FreeBSD"; } else if(ereg("NT 4.0",$uagent)) { $distro="NT"; } else if (ereg("NT 5.0",$uagent)) { $distro="2000"; } else if (ereg("NT 5.1",$uagent)) { $distro="XP"; } else if (ereg("NT 5.2",$uagent)) { $distro="XP"; }else if (ereg("NT 6.0",$uagent)) { $distro="Vista"; } else { $distro="Other"; } return $distro; } function ip(){ return $_SERVER['REMOTE_ADDR']; } function ip2(){ if ($ip2 == getenv('HTTP_CLIENT_IP')) {} else if ($ip2 == getenv('HTTP_X_FORWARDED_FOR')) {} else if ($ip2 == getenv('HTTP_X_FORWARDED')) {} else if ($ip2 == getenv('HTTP_FORWARDED_FOR')) {} else if ($ip2 == getenv('HTTP_FORWARDED')) {} else { $ip2 = "0"; } return $ip2; } } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted December 15, 2007 Share Posted December 15, 2007 Turn on error reporting and display errors. You need them while devloping. Post the errrors you recieve if you can't resolv them yourself. Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 That was a GREAT idea, i forgot about a class's constructor (or whatever it's called). But, unfortunately, that didn't work.... Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 If i could, i would LOVE to, but that's another story too: http://www.phpfreaks.com/forums/index.php/topic,172044.msg762415.html#msg762415 Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 If you can't access the php.ini file do it using ini_set. Quote Link to comment Share on other sites More sharing options...
dbo Posted December 15, 2007 Share Posted December 15, 2007 Put this at the top of the page with all your code on it. (the one you're pointing your browser at) ini_set("display_errors", "1"); error_reporting(E_ALL); ini_set("error_reporting", E_ALL); Quote Link to comment Share on other sites More sharing options...
Alex-Grim Posted December 15, 2007 Author Share Posted December 15, 2007 Solved. : http://phpbuilder.com/board/showthread.php?p=10840762#post10840762 I misspelled function, and i can use errors now too. Thnx for your help guys. Quote Link to comment 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.