Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

mysql_fetch_array not working in my code :- I got an error like this ...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\finalreports\generatereport.php on line 38

My code is So far ....

if(array_key_exists('server_guid',$_GET))
{
    $guids = $_GET['server_guid'];
    $guid_array = explode(",",$guids);

    //$reporttype = "Server Resources";

    for($i=0 ; $i<count($guid_array); $i++)
    {
        $query = "select vid from vendor_registration where bussname='".$guid_array[$i]."'";
        $result = mysql_query($query);



        while($row = mysql_fetch_array($result))
        {
            $name_array[$i] = $row[0];

        }
    }
}
share|improve this question
1  
Hello Bobby Tables! –  Marc B Sep 1 '11 at 17:48
 
@David, you keep posting questions full of SQL-injection holes, please see: please see: stackoverflow.com/questions/332365/… and stackoverflow.com/questions/5811834/… and stop injecting unescaped user data into a query. –  Johan Sep 2 '11 at 13:13
add comment

2 Answers

up vote 5 down vote accepted

Make sure the result is not tainted:

$result = mysql_query($query) or die(mysql_error());
share|improve this answer
add comment

Your query may be returning an error:

if (($result = mysql_query($query)) === false) {
    echo "Error running query: " . mysql_error() . "\n";
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.