Forum Moderators: coopster
Here is my mysql.inc.php page section:
function sqlquery($sql) {
global $conn;$result = mysql_query($sql,$conn) or die("Could not query MySQL: " . mysql_error());
return $result;
}
Here is the call on the default page:
<?php
$sql = "SELECT * FROM table WHERE column = '$id' AND status <> 4 ORDER BY name";
$result = sqlquery($sql);
$numofrows = sqlcountrow($result);
?>
And here is the error:
Warning: mysql_query(): 11 is not a valid MySQL-Link resource in /www/myfolder/includes/mysql.inc.php on line 28
Could not query MySQL:
If anyone can help me work out what this error is, I will greatly appreciate it. I run quite a few other SQL queries, and they work fine..just not a few on the default page.
Thanks. wruk999.
So basically, where's is that $conn var set? And also, anything else in your script that could possibly reset its value to something invalid?
just thoughts, could something else...
mavherick
I never use anything but the actual query in mysql_query()
This ties into what maverhick is asking, 'cause here is the bit above in the mysql.inc.php page:
function sqlconnect() {
global $sqldb;
global $conn;
global $sqluser, $sqlpass, $sqlhost;$conn = mysql_connect($sqlhost, $sqluser, $sqlpass) or loadmaintenance() or die("Could not connect to MySQL: " . mysql_error());
$selected = mysql_select_db($sqldb, $conn) or loadmaintenance() or die("Could not select database: " . mysql_error());
}
thanks for your help. wruk999
<added>that "cannot select dbase" is only occuring on the select statement in my first post. my language selector, which is used throughout, is still working, without the $conn var being present in the query string)</added>