/    Sign up×
Community /Pin to ProfileBookmark

i have this code and it it keeps saying this error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

[code=php]<?php

include(“rankdb.php”);
$query = mysql_query(“SELECT * FROM `users`”) or die(mysql_error());
while($row = mysql_fetch_array($query))
{
$points = 0;

$points += $row[‘wall’] * 50 + $row[‘lab’] * 80 + $row[‘image’] * 2000 + $row[‘units’] * -500;

$query = “UPDATE `users` SET `score` = ‘$points’ WHERE `username` = ‘” . $row[‘username’] . “‘;”;
$result = mysql_query($query);
}
?>[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscNov 07.2007 — Make sure that a connection to the database has been established before you make the query, seems to me that that is the likely problem that would be throwing out that error.
Copy linkTweet thisAlerts:
@mitchellauthorNov 07.2007 — i have this in the rank db:

[code=php]$dbhost = '';
$dbusername = '';
$dbpasswd = '';
$database_name = '';

// Database Stuff
$connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");[/code]
Copy linkTweet thisAlerts:
@ryanbutlerNov 07.2007 — Perhaps I'm missing something with your attached PHP code but the variables in rankdb.php have no values assigned to them. Therefore, when you pass them in as a parameter, you're getting nothing back in your connection string variable. Fill it in with the necessary info.
Copy linkTweet thisAlerts:
@mitchellauthorNov 07.2007 — yes i have but it still doesnt work
×

Success!

Help @mitchell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...