View Single Post
Old Oct 27th, 2004, 10:27 AM   #10
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
You have to send the mysql resource as an argument to the function so that the variable can be used inside of the function.

When you open the connection with mysql_connect assign the connection to a variable. Although it will be assumed in all other parts of your code, you will need this when calling your function.

function getMessages($resource) {
 $rs = mysql_query( "SELECT * FROM MINICHAT ORDER BY NB", $resource );

 $ret = Array();
 $count = 0;

 while ( $msg = mysql_fetch_assoc($rs))
   $ret[$count++] = date('h:m', $msg['ITSTIME'] )." ".$msg['LOGIN']." >".$msg['MESSAGE'];

 return $ret;
}

Im not 100% on that so you could also try...

function getMessages() {
 $rs = mysql_query( "SELECT * FROM MINICHAT ORDER BY NB");

 $ret = Array();
 $count = 0;

 while ( $msg = mysql_fetch_assoc($rs))
   $ret[$count++] = date('h:m', $msg['ITSTIME'] )." ".$msg['LOGIN']." >".$msg['MESSAGE'];

 return $ret;
}

And that could just work.

Hope ive helped.
__________________

tempest is offline   Reply With Quote