This topic is locked

strange error

2/2/2008 11:32:03 AM
PHPRunner General questions
V
vytb author

Today I started receiving the following error message on the page that always worked
mysql_num_rows(): supplied argument is not a valid MySQL result resource
DB was not migrated and permissions were not changed (this can be the reason after some people on the web)
here is the code on the beforeadd/beforeupdate pages (PHPR 4.1)
[codebox]$result = mysql_query("SELECT * FROM _st_course where SubjectId=".$_SESSION['_st_inter_masterkey1']);

$num_rows = mysql_num_rows($result);

$values['Course_count'] = $num_rows;
return true;[/codebox]
both keys are SubjectId

mastertable is _st_inter

child table is _st_course
I'm displaying the number of child records on the master table as Course_count.
Any ideas about the problem?

J
Jane 2/4/2008

Hi,
try to print your SQL query before executing:

global $conn;

echo "SELECT FROM _st_course where SubjectId=".$_SESSION['_st_inter_masterkey1'];

$result = mysql_query("SELECT
FROM _st_course where SubjectId=".$_SESSION['_st_inter_masterkey1'],$conn);

$num_rows = mysql_num_rows($result);

$values['Course_count'] = $num_rows;
return true;

V
vytb author 2/5/2008

Hi,

try to print your SQL query before executing:



Solved!
It was not a db issue. The user was trying to edit from the list page of all the records. Therefore, session variable did not function here. I took off this code and used count() in the the query. However this (I think 'group by') fools the PHPR in counting the 'details' pages so it always counts one page and one detail but shows all.