redsatori Posted November 17, 2006 Share Posted November 17, 2006 Hello:I am getting a weird server error that I cannot figure out when I try to implement OO PHP in my website. Any help would be appreciated. Thank you.The following error is generated:PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\path\to\resource\ini.config.inc on line 48Here is the code that generates this error. A few notes before I start.index.php has the following code:require_once '/path/to/resource/ini.config.inc';ini.config.inc contains a data class to hold all the variables for my setup.require_once '/path/to/resource/class.conn.inc';public function __construct($host, $user, $pass) {$this->host = $host;$this->user = $user;$this->pass = $pass;$conn = new Connection($this->host, $this->user, $this->pass);$conn->select('config');$sql = 'SELECT id, value FROM data ORDER BY id';$result = $conn->query($sql);while ($row=mysql_fetch_array($result)) { $this->$row['id'] = $row['value']; } $conn->disconnect();}And finally class.conn.php has the following function:public function query($sql) { $result = mysql_query($sql, $this->link); return $result; }The bold line in the ini.config.inc file is the one where the error points to.I cannot figure out how to make this work, unless I have to do it in the connection class itself instead of the config class.I have tried a number of things without success, including bare mysql calls in the constructor itself. All to no avail. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 17, 2006 Share Posted November 17, 2006 That error message means that the parameter to mysql_fetch_array is not a resource, which means that the query didn't work. Try printing out MySQL errors at various places to determine why the query is not working. Link to comment Share on other sites More sharing options...
redsatori Posted November 17, 2006 Author Share Posted November 17, 2006 That error message means that the parameter to mysql_fetch_array is not a resource, which means that the query didn't work. Try printing out MySQL errors at various places to determine why the query is not working.Thanks. Took me a second to turn all the tokens back on, but it wasn't selecting the right database, thus giving me that error. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now