Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > strange MySQL result problem
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 4th July 00:05
cparker
External User
 
Posts: 1
Default strange MySQL result problem



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/
  Reply With Quote


 


2 4th July 07:22
kilimajer
External User
 
Posts: 1
Default strange MySQL result problem



Is your query correct?

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);
}
  Reply With Quote
3 4th July 22:37
cparker
External User
 
Posts: 1
Default strange MySQL result problem


Marek Kilimajer <mailto:kilimajer@webglobe.sk>
on Friday, October 17, 2003 5:29 PM said:

Yes.

[snip]


I tried your mod and I still saw the error, but your mod did not trigger
any output.


Chris.

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
  Reply With Quote


 


Reply


Thread Tools
Display Modes




666