0

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 ?

Edited by Nick Evan: Added [CODE] tags

6
Contributors
12
Replies
13
Views
6 Years
Discussion Span
Last Post by stoopkid
0

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.

0

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..

0

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.

0

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

its really weird and frustrating

0
$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

0

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

0

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.

0

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.

0

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 ?

0
$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....

Edited by Dani: Formatting fixed

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.