help with mysql_fetch_array error

I am having a problem with the mysql_fetch_array on line 21 its giving me a error and I dont no why. Could anyone help?
[code]
<?php
include("lcr88.php");

mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname");
$query = "SELECT * FROM extra WHERE o = '1'";
$result = mysql_query($query)
or die("Couldn't Execute Query");
$row = mysql_fetch_array($result);
extract($row);

$addmoney = $nextupdate;

$time = time();

mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname");
$query = "SELECT * FROM members WHERE valid = '1'";
$result = mysql_query($query)
or die("high");
while($row = mysql_fetch_array($result)) // THIS IS WHERE THE PROBlEM IS
{
extract($row);
$min = $minerals;

if($time >= $addmoney) {

$newmin1 = $unit1*100;
$newmin = $newmin1+$min;

mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname");
$query = "UPDATE members SET minerals = '$newmin' WHERE username = '$username'";
$result = mysql_query($query)
or die("Couldn't Execute Query");

$newtime = time()+3600;

mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname");
$query = "UPDATE extra SET nextupdate = '$newtime' WHERE o = '1'";
$result = mysql_query($query)
or die("Couldn't Execute Query");
}
}


include("include.php");

?>
[/code]

Comments

  • The thing that I would do now, because you never know what happens when a query fails (and that is what I think happened). Try to put this after you executed the last query (where is goes wrong) and before you go into the while loop:
    [code]
    $error = mysql_error(YOUR CONENCTION VARIABLE);
    echo "$error";
    [/code]

    You have to create a variable that holds your connection to see what happened. It would look like this:
    [code]
    $connection = mysql_connect("$dbhost","$dbuser","$dbpass");
    [/code]

    Analyze the error and fix the problem.

    Hope this helps.
    --=][tReShR][=--

  • Well it took me 3 hours but i figured out the prob. thanks for your help.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories