Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Lcbo\flash_import.php on line 6

this is the error i get from this code:

require_once("Connections/LCconnect2.php");

$myquery = mysql_query("SELECT pro_brand FROM product_information ORDER BY pro_id DESC"); 
print "&winetitle=";
while($row=mysql_fetch_array($myquery)){       //<----line 6
print $row['pro_brand']."|";
}

is it something to do with my query ?

Try this instead...

$myquery="SELECT pro_brand FROM product_information ORDER BY pro_id DESC";
    if ($result=mysql_query($myquery)) {  
    while ($row=mysql_fetch_assoc($result))  
    {

echo $row['pro_brand']; 
}}

That works for me. i think the $myquery = mysql_query("select... may have caused issues for you.

the echo is blank but the error is gone..

where else could the problem be ?

the connection works fine too.

thanks for the help by the way..

have you tried running the sql directly in phpmyadmin to see if its not a problem with the statement. i cant see why else it wouldnt work.

yep it works in as a query in phpmyadmin...

its really weird and frustrating

check for spelling errors....often thats the case......

$myquery="SELECT pro_brand FROM product_information ORDER BY pro_id DESC";
$result=mysql_query($myquery);
    if (!$result) {  
        die("Error:"mysql_error());
    }
    while ($row=mysql_fetch_assoc($result))  
    {
      echo $row['pro_brand']; 
    }

post any error you find

Ill try what you posted..

the error was this:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Lcbo\flash_import.php on line 6

Add or die(mysql_error()); to the query line so you can check what is happening, probably $myquery is returning bool(false) and so you get an error on line 6.

The error means your query is not returning any rows. Make sure that your query is correct, and that your database connect information is also right. These errors usually stem from the database information being wrong, or you mistyping the table name.

I checked the spelling about 800 times...by the end I was probably crossed though.

to solve the problem i simply made a Recordset named "Brand" and it found the content from there..

the problem now is that when i echo information it only displays one thing and i want the full list

this is what i tried:

$product = array($row_Brand['pro_brand']."<br />");
//$proid = array($row_Brand['pro_id']);

for($x = 0; $x < sizeof($product); $x++ )
echo "&winetitle=".$product[$x];

I realize its probably way off..

any suggestions ?

$query ="SELECT pro_brand FROM product_information ORDER BY pro_id DESC";
$result =mysql_query($query);
while ($row=mysql_fetch_array($result))

{

echo "<br/>";

    echo $row['pro_brand'];  
}

Let me know if this works....

No idea what you're trying to do, but a simple while loop is going to display all of the rows that your query results in.

require db.php

$sql = "SELECT pro_brand FROM product_information ORDER BY pro_id DESC";
 $result = mysql_query($sql);
  while($r = mysql_fetch_array($result)) {
    echo "$r['pro_band']<br>";
}

If the above code doesn't work for you, than you have some real problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.