警告:mysql_query():4不是有效的MySQL-Link资源 [英] Warning: mysql_query(): 4 is not a valid MySQL-Link resource
问题描述
我收到了这个警告:
mysql_query():4不是有效的MySQL-Link资源。
导致此警告的行是:
mysql_query(" insert into $ tablename(id,priority)values(''$ id'',
''0.00'')",$ link2);
据我所知,问题是$ link2不是有效的MySQL-
链接资源"。
我用这种方式指定$ link2:
$ link2 = mysql_connect(" localhost"," loctopu_user"," userpsw" );
它似乎对我的代码中的某个地方有效(因为我/
成功地将它与不同的mysql_queries一起使用)。我调用一个函数后出现问题
。之后,$ link2不再是一个有效的MySQL-Link
资源。在函数中我打开并关闭另一个连接
到MySQL服务器。但这样做我使用另一个名称作为链接
资源。此外,我认为,函数
中使用的链接资源应该被视为局部变量,因此它应该在函数外部的
中不可见。
那么,它能是什么?一个函数如何破坏链接资源
调用函数的程序?
谢谢。
Hi,
I got this warning:
mysql_query(): 4 is not a valid MySQL-Link resource.
The line which cause this warning is:
mysql_query("insert into $tablename (id,priority) values(''$id'',
''0.00'')", $link2);
As far as understand the problem is that $link2 is "not a valid MySQL-
Link resource".
I specify $link2 in this way:
$link2 = mysql_connect( "localhost","loctopu_user","userpsw" );
And it seems to be valid to some place in my code (because I
successfully use it with different mysql_queries). The problem appears
after I call one function. After that $link2 is not a valid MySQL-Link
resource anymore. In the function I open and close another connection
to the MySQL server. But doing that I use another name for the link
resource. Moreover, I think, the link resource used in a function
should is treated a local variable, so it should be invisible from the
outside of the function.
So, what can it be? How a function can destroy the link resource of
the program which calls the function?
Thank you.
推荐答案
tablename(id,priority)values(''
tablename (id,priority) values(''
id'',
''0.00'')" ;,
id'',
''0.00'')",
link2);
据了解问题是
link2);
As far as understand the problem is that
这篇关于警告:mysql_query():4不是有效的MySQL-Link资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!