Looks like you have a scope issue :

 $a = 'foo';

 function bar()
 { 
   $a = 'bar';
 }

 bar();

 print $a; // prints foo

outside of the function, $a has not been affected.  want it to be?  then
try something like :

 $a = 'foo';

 function bar()
 {
   global $a;

   $a = 'bar';
 }

 bar();

 print $a; // prints bar

see how that works?  now if you're just wanting to get a row count then
try something like :

 function getRowCount($table)
 {
   $r = mysql_query("SELECT count(*) FROM $table");

   return mysql_result($r,0); 
 }

 print getRowCount('tablename');

it's much faster to rely on sql count function as opposed to selecting all
data and using x_num_rows.  regarding functions and scope, see :

  http://www.php.net/manual/en/functions.php
  http://www.php.net/manual/en/language.variables.scope.php


regards,
philip



On Tue, 24 Apr 2001, Martin [ISO-8859-4] Skjöldebrand wrote:

> I have a function on an include page that says
> 
> function update_stuff($database)
> {
> include("includes/connect.inc.php");
> include("config/db.conf.php");
> $query="SELECT * FROM $database";
> $query_res=mysql_query($query, $mysql_link);
> $isequip=mysql_num_rows($query_res);
> }
> 
> If I call it from a script as
> update_stuff(equipment);
> 
> I don't get any result (I want to page to automagically update it's 
> contents) while if I include the query lines after each edit case
> it does update the page contents.
> 
> I'm missing something basic, but what?
> 
> Martin S.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to