mysql_query(): supplied argument is not a valid MySQL-Link resource
From: aa (aa_at_virgin.net)
Date: 01/15/05
- Next message: Andy Hassall: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Previous message: Bob Bedford: "Best way to do so."
- Next in thread: Andy Hassall: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Reply: Andy Hassall: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Reply: Norman Peelman: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 14 Jan 2005 23:25:14 -0000
I use the following fragment of code to output datf from MySQL:
======================================================
$chan = mysql_connect ($db_host, $username, $password);
mysql_select_db ($DB_name, $chan);
$resultid = mysql_query ("select name_ru, description_ru, retail, dealer
from lasershot WHERE le='1'", $chan);
.......
======================================================
This was working fine.
Then I needed to repeat this code (except for the first two lines) several
times, every time for a different value of le
I placed everything starting from lime 3 inside {}, made is a function and
called this function like that:
$chan = mysql_connect ($db_host, $username, $password);
mysql_select_db ($DB_name, $chan);
function write_table()
{
$resultid = mysql_query ("select name_ru, description_ru, retail, dealer
from lasershot WHERE le='1'", $chan);
......
}
write_table();
Now I am getting this error:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
in /files/home2/andrei/lasershot/pricelist_sql_ansi_split.php on line 41
(line 41 is the former line 3:
$resultid = mysql_query ("select name_ru, description_ru, retail, dealer
from lasershot WHERE le='1'", $chan);
Why does the argument stopped being valid?
When I moved the first two lines inside the function, the line
$chan = mysql_connect ($db_host, $username, $password);
started generating error:
Warning: mysql_connect(): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2) in
/files/home2/andrei/lasershot/pricelist_sql_ansi_split.php on line 40
Does this mean that mysql_query() and mysql_connect() cannot be called from
within a function?
- Next message: Andy Hassall: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Previous message: Bob Bedford: "Best way to do so."
- Next in thread: Andy Hassall: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Reply: Andy Hassall: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Reply: Norman Peelman: "Re: mysql_query(): supplied argument is not a valid MySQL-Link resource"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]