Re: mysql_query(): supplied argument is not a valid MySQL-Link resource
From: Paul Barfoot (Paul_at_theglobalfamily.fsworld.co.uk)
Date: 01/15/05
- Next message: Matthias Esken: "Re: php function for syntax higlighting in html ?"
- Previous message: Ira Baxter: "Re: general parser + compiler"
- In reply to: aa: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Next in thread: aa: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Reply: aa: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 15 Jan 2005 20:53:06 -0000
Hi aa
When I had my first attempt at using functions in a PHP script I had similar
problems. I got round it by passing all variables outside the function into
it in the function call.
function write_table()
{
$resultid = mysql_query ("select name_ru, description_ru, retail, dealer
from lasershot WHERE le='1'", $chan);
......
}
write_table();
becomes
function write_table($channel)
{
$resultid = mysql_query ("select name_ru, description_ru, retail, dealer
from lasershot WHERE le='1'", $channel);
......
}
write_table($chan);
See if that helps.
-- Paul Barfoot "aa" <aa@virgin.net> wrote in message news:41e8fdb1$0$22490$ed2619ec@ptn-nntp-reader03.plus.net... >I looked up "PHP and MySQL Web Developement" by Luke Welling and Laura > Thomson. > In the para "Scope of variables" it reads (the book is translated into > Russian and I translate is back into English): > "Variables declared as global in a scenario are seen throughout the > scenario, but not seen from within functions. By default all the variables > declared in a scenario outside functions are global." > > It looks like if query MySQL from a function, I will have to put all the > database related variables inside the function. And therefore to open and > close a connection to the database very time I run a query. > In my case I am building a page by sending different queries to the > database. > Opening and closing the connection for every query looks like an > unnecessary > overhead. > > Can I get round it? > > > >
- Next message: Matthias Esken: "Re: php function for syntax higlighting in html ?"
- Previous message: Ira Baxter: "Re: general parser + compiler"
- In reply to: aa: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Next in thread: aa: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Reply: aa: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|