Re: mysql_query(): supplied argument is not a valid MySQL-Link resource

From: aa (aa_at_virgin.net)
Date: 01/15/05


Date: Sat, 15 Jan 2005 11:09:56 -0000

Thanks, Andy, it makes a lot of sense. Even the requirement to expressly
declare a variable as a global one.
However it did not sort my problem out. I played with one variable $db_host:
======================================================
global $chan, $db_host, $username, $password, $DB_name,$DB_name;
$db_host = "humbug";
function write_table()
{
$username = "myusername";
........ $password, $DB_name,$DB_name are assigned values here
$chan = mysql_connect ($db_host, $username, $password);
if ($chan==false)
                 mysql_error();
.....
}
===================================
produces the same error as before:
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 42

However if I move
$db_host = "humbug";
inside the function it works fine. Which means that the global variable are
not seen inside a function, or I declare them wrongly



Relevant Pages

  • Re: Overcoming Transact-SQL ORDER BY limitations
    ... declare @s nvarchar ... I could use a calculated field and sort on ... >> SortOrder ... >> In my table, JobNo is a bigint, and the other fields are string fields. ...
    (microsoft.public.sqlserver.programming)
  • Re: Two things that bug me about C#
    ... If you want this sort of thing it can be had in VB.NET via its "modules" ... > 1) you can't declare anything outside of a class, enum, etc. ... > declare globals right after the namespace declaration. ... and thus waste time and space. ...
    (microsoft.public.dotnet.languages.csharp)
  • we shiver the systematic coverage
    ... We declare them, then we sort of whisper Walt and Edith's maximum shot. ...
    (sci.crypt)
  • Re: Telegraph Discrimination Story, more information
    ... The SA may have to declare itself, officially, a religious organisation ... I declare myself a religious organisation with a membership ... i.e. what sort of organisation is it now? ...
    (uk.rec.scouting)
  • Re: Query Help
    ... the sort order, since you have no column in any table. ... DECLARE @id INT ... DINNER JOIN Table2 ... I can't seem to get the correct query. ...
    (microsoft.public.sqlserver.programming)