phpusers Posted October 23, 2008 Share Posted October 23, 2008 Hi, I am new to php. Installed PHP and mysql on windows xp. Any php code with the class reference class -> memberfunction is not executing. What can be the problem? Is it something to do with some missing extension for oops support in PHP. Also when i select all extensions during installation my PHP stops running any page and gives the error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: Can someone please help please?? Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/ Share on other sites More sharing options...
DarkWater Posted October 23, 2008 Share Posted October 23, 2008 We'd need to see code. Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-673027 Share on other sites More sharing options...
phpusers Posted October 24, 2008 Author Share Posted October 24, 2008 below is one of the code, but any code i use that has -> operator does not execute beyond it. <html> <head> </head> <body> <? // Our Database Class include("lib/dal.php"); // Instantiate our Database Class $db = new Dal(); // Query! $resArr = $db->query("SELECT * FROM users WHERE id != 1"); echo '<table><tr><th>UserID</th><th>UserName</th>'; foreach($resArr as $user) { echo '<tr><td>'.$user['id'].'</td><td>'.$user['username'].'</td></tr>'; } echo "</table>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-673535 Share on other sites More sharing options...
genericnumber1 Posted October 24, 2008 Share Posted October 24, 2008 we'd need to see this "dal.php" as well.... Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-673992 Share on other sites More sharing options...
phpusers Posted October 26, 2008 Author Share Posted October 26, 2008 class Database { var $database_name; var $database_user; var $database_pass; var $database_host; var $database_link; function Database() { $this->database_user = "motoma"; $this->database_pass = ""; $this->database_host = "localhost"; $this->database_name = "dalDatabase"; } function changeUser($user) { $this->database_user = $user; } function changePass($pass) { $this->database_pass = $pass; } function changeHost($host) { $this->database_host = $host; } function changeName($name) { $this->databse_name = $name; } function changeAll($user, $pass, $host, $name) { $this->database_user = $user; $this->database_pass = $pass; $this->database_host = $host; $this->database_name = $name; } function connect() { $this->database_link = mysql_connect($this->database_host, $this->database_user, $this->database_pass) or die("Could not make connection to MySQL"); mysql_select_db($this->database_name) or die ("Could not open database: ". $this->database_name); } Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-674986 Share on other sites More sharing options...
genericnumber1 Posted October 26, 2008 Share Posted October 26, 2008 As you can see, there is no query() method, hence it saying there is no query() method. Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-675015 Share on other sites More sharing options...
phpusers Posted October 30, 2008 Author Share Posted October 30, 2008 The code actually did not get pasted fully. the query method was there. It is given below..... function iquery($qry) { if(!isset($this->database_link)) $this->connect(); $temp = mysql_query($qry, $this->database_link) or die("Error: ". mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-678628 Share on other sites More sharing options...
phpusers Posted October 30, 2008 Author Share Posted October 30, 2008 also there is a query method: function query($qry) { if(!isset($this->database_link)) $this->connect(); $result = mysql_query($qry, $this->database_link) or die("Error: ". mysql_error()); $returnArray = array(); $i=0; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) if ($row) $returnArray[$i++]=$row; mysql_free_result($result); return $returnArray; } } Link to comment https://forums.phpfreaks.com/topic/129790-help-code-aftler-is-not-recognized-some-problem-with-class/#findComment-678630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.