Jump to content

Help !! Code aftler -> is not recognized. Some problem with class???


phpusers

Recommended Posts

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??

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>

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);       

    }

 

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());       

    }

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;

    }

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.