Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Easy question...


Message #1 by "Bill" <bige88fan@c...> on Tue, 5 Nov 2002 16:02:53
Wow, thanks for the quick response guys. Justin I just tried to connect in 
the function WITHOUT the resource ID and it still worked. Also thanks for 
your input Jonas! 










> No. It should be fine once you have connected once but 
you will need to make the resource id global in any
functions that you write.

cheers Justin.

> -----Original Message-----
> From: Bill [mailto:bige88fan@c...]
> Sent: 05 November 2002 16:03
> To: professional php
> Subject: [pro_php] Easy question...
> 
> 
> Just wanted to know something. Let's say I have a file, which 
> calls for 
> another function inside of another file which is included 
> into the origin 
> file. I have connected to the mysql database inside of the 
> origin file, is 
> it neccessary to connect inside of each indivual function if 
> I am already 
> connected in the origin file? Here is an example:
> 
> <?php
> //origin.php
> 
> connect();
> 
> get_data("test_tlb","car");
> 
> ?>
> 
> <?php
> //functions.php
> 
> function get_data($table,$field){
> connect();
> 
> $query = mysql_query("SELECT $field FROM $table");
> $result = mysql_result($query,0,$field);
> 
> }
> ?>
> 
> Basically what connect does is connect to the database. I 
> made a function 
> for it. So is it really neccessary to call connect() inside of the 
> function get_data()? I'm thinking that if it's not, could it 
> increase the 
> speed of my script slightly? And also, any other tips on 
> increasing the 
> speed of any script? Thanks guys!
> ---
> Change your mail options at http://p2p.wrox.com/manager.asp or 
> to unsubscribe send a blank email to 
> 
> 

  Return to Index