Re: [PHP] can't figure out this mysql error

2004-01-27 Thread Jason Wong
On Tuesday 27 January 2004 02:23, Chris W. Parker wrote:

 If I put the two functions mysql functions within the query method I
 created I get an error on those two lines BUT the program continues as
 normal WITH the data being printed to the page just as I want it to.
 Clearly the mysql resource being complained about is actually valid and
 not invalid considering that the data I'm trying to retrieve is printed
 to the page.

 Any other ideas?

Post some *concise* code which illustrates the problem.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Your supervisor is thinking about you.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] can't figure out this mysql error

2004-01-26 Thread Chris W. Parker
Jason Wong mailto:[EMAIL PROTECTED]
on Friday, January 23, 2004 10:03 PM said:

 Time to put the php debugger in action -- echo all your variables to
 see that contain what you expect them to contain.

'echo $this-Result;' prints Resource id #2

'print_r($this-Result);' prints Resource id #2

If I put the two functions mysql functions within the query method I
created I get an error on those two lines BUT the program continues as
normal WITH the data being printed to the page just as I want it to.
Clearly the mysql resource being complained about is actually valid and
not invalid considering that the data I'm trying to retrieve is printed
to the page.

Any other ideas?


Thanks,
Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] can't figure out this mysql error

2004-01-23 Thread Chris W. Parker
Jason Wong mailto:[EMAIL PROTECTED]
on Thursday, January 22, 2004 8:49 PM said:

 The if-clause will never be evaluated because if there had been an
 error your program would have dieded on the previous line.

Heh.. yeah I thought about that as I was examining the code for this
post. But thanks for confirming.

 I'm sure if php tells you it's invalid you can bet your *** it's
 invalid! Check for errors and report with mysql_error() after _each_
 and _every_ call to the mysql_* functions.

All of what you say makes sense. Hopefully your suggestion will help me
find the problem!



Thanks,
Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] can't figure out this mysql error

2004-01-23 Thread Chris W. Parker
Chris W. Parker 
on Friday, January 23, 2004 8:54 AM said:

 All of what you say makes sense. Hopefully your suggestion will help
 me find the problem!

In looking through my code I see that I already do this. EVERY call to a
mysql function has or die($this-stop($current_line:.__LINE__));
along with the call. $this-stop() is method that prints out
mysql_errno(); and mysql_error();.

In this case the or die is not even being tripped meaning there isn't
an error. I'm beginning to think it's a bug, but it's more likely that
it's not.

Here's another bit of crazy to throw in. The function I am trying to
perform is that of adding a record to my db. Guess what? The record
insertion is successul each time. And no I'm not closing the resource/db
link before those two functions are called. They happen immediately
after the the mysql_query() function.

Sounds pretty fishy



Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] can't figure out this mysql error

2004-01-23 Thread Jason Wong
On Saturday 24 January 2004 01:07, Chris W. Parker wrote:

 on Friday, January 23, 2004 8:54 AM said:
  All of what you say makes sense. Hopefully your suggestion will help
  me find the problem!

 In looking through my code I see that I already do this. EVERY call to a
 mysql function has or die($this-stop($current_line:.__LINE__));
 along with the call. $this-stop() is method that prints out
 mysql_errno(); and mysql_error();.

 In this case the or die is not even being tripped meaning there isn't
 an error. I'm beginning to think it's a bug, but it's more likely that
 it's not.

 Here's another bit of crazy to throw in. The function I am trying to
 perform is that of adding a record to my db. Guess what? The record
 insertion is successul each time. And no I'm not closing the resource/db
 link before those two functions are called. They happen immediately
 after the the mysql_query() function.

 Sounds pretty fishy

Time to put the php debugger in action -- echo all your variables to see that 
contain what you expect them to contain.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
An expert is the person who avoids the small errors while sweeping on to the 
grand fallacy
-- Thoreau's Theories of Adaption n1
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] can't figure out this mysql error

2004-01-22 Thread Chris W. Parker
Hi.

I have a db class that accesses and executes querys as well as returns
the result (if you so choose to have it returned).

One method within this class is called query() (how genius!). It's
defined like so:

?php
function query($sql, $current_line)
{
  $this-Result = mysql_query($sql) or die($this-stop($current_line));

  if(!$this-Result)
  {
echo mysql_error();
  }

  $this-result_fields = mysql_num_fields($this-Result); // line 127

  $this-result_rows = mysql_num_rows($this-Result); // line 130
}
?

How is it possible that I'm getting the following errors?

Warning: mysql_num_fields(): supplied argument is not a valid MySQL
result resource in /home/cparker/www/schedulevark/lib/classes/db.php on
line 127

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/cparker/www/schedulevark/lib/classes/db.php on line
130
success!

I can't figure it out! It sure looks like a valid MySQL result to me! Oh
and I should mention that the query's I'm running are perfect and I can
run these two functions without error in another method (the one that
returns the results). That method is defined like so:

?php
function get_query_results()
{
  $Result_Arr = array();

// THESE LINES WORK FINE BUT I DON'T WANT THEM HERE!
//  // store the number of fields
//  $this-result_fields = mysql_num_fields($this-Result);
//
//  // store the number of rows
//  $this-result_rows = mysql_num_rows($this-Result);

  if($this-result_rows  0)
  {
while($line = mysql_fetch_array($this-Result, MYSQL_BOTH))
{
  $Result_Arr[] = $line;
}
  }

  mysql_free_result($this-Result);
  return $Result_Arr;
}
?

The reason I don't want the two mysql counting functions in the second
method is because it forces me to execute the second method within my
page before I can access those values. Sometimes I need to access those
values but don't need to return a result so I'd like to be able to leave
that second step out.

Here is the original way they are used in my page (the way I don't
want):

?php

$sql = 
SELECT field1
, field2
, field3
FROM thetable;

$object-query($sql, __LINE__);

$the_result = $object-get_query_results();

$the_result_Rows   = $object-Result_rows;
$the_result_Fields = $object-Result_fields;
?

Here is the way that I WANT it to work:

?php

$sql = 
SELECT field1
, field2
, field3
FROM thetable;

$object-query($sql, __LINE__);

$the_result_Rows   = $object-Result_rows;
$the_result_Fields = $object-Result_fields;
?



Anyone have any ideas?

If I have not been verbose enough in this email let me know and I will
try to clarify.


Thanks,
Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] can't figure out this mysql error

2004-01-22 Thread Jason Wong
On Friday 23 January 2004 09:38, Chris W. Parker wrote:

 ?php
 function query($sql, $current_line)
 {
   $this-Result = mysql_query($sql) or die($this-stop($current_line));

   if(!$this-Result)
   {
 echo mysql_error();
   }

The if-clause will never be evaluated because if there had been an error your 
program would have dieded on the previous line.

 How is it possible that I'm getting the following errors?

 Warning: mysql_num_fields(): supplied argument is not a valid MySQL
 result resource in /home/cparker/www/schedulevark/lib/classes/db.php on
 line 127

 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
 resource in /home/cparker/www/schedulevark/lib/classes/db.php on line
 130
 success!

 I can't figure it out! It sure looks like a valid MySQL result to me! Oh

I'm sure if php tells you it's invalid you can bet your *** it's invalid! 
Check for errors and report with mysql_error() after _each_ and _every_ call 
to the mysql_* functions.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If you sow your wild oats, hope for a crop failure.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php