supplied argument is not a valid MySQL result resource
| From: | Chris Fraser | Date: | Thu, 20 Jun 2002 13:30:16 +0000 |
| Subject: | supplied argument is not a valid MySQL result resource | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-103116@lists.php.net to get a copy of this message | ||
Greetings,
I'm new to php and understand the basics, but I don't understand why I'm getting
this error.
Okay, I've been working on this site after upgrading to phpwebsite 8.2 when it was released.
I've finally gotten around to dealing with user information (user.php).
I added three new fields to the end of the users table: scaname (varchar(60)), group (varchar
(60)), and officer (int(1)).
I want to display scaname and group on the user's account info page. I added both to the two
mysql query lines.
$result = mysql_query("select name, femail, url, bio, scaname, group from " .
$table_prefix."users where strcmp(uname,'$uname')=0");
My problem is if I just add scaname, everything works fine in the adjusted display code. When I
add the group variable to the query lines. I get errors. Also, if I add officer everything is
fine. It's just when I add the group variable.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:
\Internet\Apache\htdocs\siteb\auroratest\user.php on line 158
line 158 $userinfo = mysql_fetch_array($result);
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Internet
\Apache\htdocs\siteb\auroratest\user.php on line 172
line 172 if((mysql_num_rows($result)==1) && ($userinfo[name] || $userinfo[url] || $userinfo
[femail] || $userinfo[bio] || $userinfo[scaname] || $userinfo[group])) {
I'm running apache 2.0.35 with php 4.2.1 and the latest mysql on WinXP.
139 function userinfo($uname, $bypass=0) {
global $user, $cookie;
include("config.php");
if ($user_dblocation)
{
@mysql_select_db("$user_dbname") or die ("Unable to select database");
145 $result = mysql_query("select name, femail, url, bio, scaname from " .
$table_prefix."users where strcmp(uname,'$uname')=0");
//$res = mysql_query("select help_system from ".$table_prefix."flags");
//list($help_system) = mysql_fetch_row($res);
@mysql_select_db("$dbname") or die ("Unable to select database");
150 }
else
{
$result = mysql_query("select uid, name, femail, url, bio, scaname from " .
$table_prefix."users where strcmp(uname,'$uname')=0");
155 //$res = mysql_query("select group from ".$table_prefix."users where
strcmp
(uname,'$uname')=0");
//list($group) = mysql_fetch_row($res);
}
$userinfo = mysql_fetch_array($result);
if(!$bypass) cookiedecode($user);
160 include("header.php");
if($uname == $cookie[1]) {
$box_title = "<span class=\"type4bigger\">" . htmlspecialchars($uname);
$box_title .= ", Welcome to $sitename ! </span>";
165 //if($help_system)
// $box_title .= help("user");
}else{
$box_title = "<span class=\"type4bigger\">" . htmlspecialchars($uname) .
"</span>";
if($help_system)
170 $box_title .= help("user");
}
172 if((mysql_num_rows($result)==1) && ($userinfo[name] || $userinfo[url] ||
$userinfo[femail]
|| $userinfo[bio] || $userinfo[scaname] || $userinfo[group])) {
The rest of the function is displaying the results.
--
"The dogmas of the quiet past are inadequate for the stormy present. The occasion is piled high
with difficulty, and we must rise to the occasion. As our case is new, so we must think anew,
and act anew. We must disentrall ourselves, and then we shall save our country.We can not escape
history. We will be remembered, in spite of ourselves. The fiery trial through which we pass
will light us down in honor or dishonor, to the last generation. We shall nobly save, or meanly
lose our last best hope of Earth." Annual Message to Congress, Concluding
Remarks, December 1, 1862
-
President Abraham Lincoln
Copyleft 2001: http://www.gnu.org/licenses/fdl.html