0

I'm a beginner and I have a error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\VertrigoServ\www\index.php on line 35

and the code...

$sresult = mysql_query("SELECT code, location FROM banners");
while ($row_s = mysql_fetch_array($sresult))
{
    $banner[$row_s["location"]]=$row_s["code"];
}

2 Answers 2

1

Try this

$sresult = mysql_query("SELECT code, location FROM banners");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
while ($row_s = mysql_fetch_array($sresult))
{
    $banner[$row_s["location"]]=$row_s["code"];
}

And check what the error is.

Sign up to request clarification or add additional context in comments.

Comments

0

Something is wrong with the query. try:

$result = mysql_query("..");
if(!$result){
  echo "Query error: " . mysql_error();
}

2 Comments

or die() :-( :-( phpfreaks.com/blog/or-die-must-die -- I never understood why people keep using this ... Or even started using it in the first place...
Agreed on die(), I, personally, have NEVER used it in my own code, but it was the first thing that popped in mind when writing here, strange :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.