Try:
function query($sql, $current_line)
{
$this->Result = mysql_query($sql)
or die($this->stop($current_line));
if(!$this->Result) {
echo mysql_error();
} $this->Result_total_fields = mysql_num_fields($this->Result);
$this->Result_total_rows = mysql_num_rows($this->Result);
}Chris W. Parker wrote:
Hey peeps.
Let me be quick (or try to at least).
Here is a snippet of my db class.
function query($sql, $current_line) { $this->Result = mysql_query($sql) or die($this->stop($current_line));
// the following two lines work if they are in the next // method get_query_results() but not when they are in // this method. $this->Result_total_fields = mysql_num_fields($this->Result); $this->Result_total_rows = mysql_num_rows($this->Result); }
function get_query_results() { $this->Result_Arr = array();
if($this->Result_total_rows > 0) { // initialize counter while($line = mysql_fetch_array($this->Result, MYSQL_BOTH)) { $this->Result_Arr[] = $line; } }
mysql_free_result($this->Result);
return $this->Result_Arr; }
Ok. As the comments in the first method state, those two lines of code do not work* when they are used in the first method. If I put them down into the get_query_results() method they work fine. I can't figure out why this is happening since my code is syntactically correct.
Chris.
* By "do not work" I mean it throws the error "supplied argument is not a valid MySQL result resource". -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

