Find the error (trivia :))

Discussion in 'Software' started by CoreOxide, Aug 13, 2007.

  1. CoreOxide

    CoreOxide Private E-2

    Heya;

    First, I'm so sorry if this is not the place, but it's urgent so be nice and help :)

    Now, there is this script, that sould run N times according to the length of the array, but only runs once... WHY?!

    <?
    include "../services/db_connect_gallery.php";
    $query = mysql_query("SELECT count(*) as total FROM `image_source` WHERE cat='$cat_id'") or die(mysql_error());
    $row = mysql_fetch_array($query, MYSQL_ASSOC);
    $i = $row['total'];
    $flag = "1";
    $db = mysql_query("SELECT * FROM image_source WHERE id='$flag' AND vaild='Yes' AND cat='$cat_id'") or die(mysql_error());
    while(($row = mysql_fetch_array($db))&&($i >= "0")) {
    echo $i;
    echo "image_array[{$flag}] = {$row['IMGLink']};\n";
    echo "image_name_array[{$flag}] = {$row['IMGName']};\n";
    echo $i;
    $flag++;
    $i--;
    echo $i;
    }
    ?>
    }
     
  2. whoru_18

    whoru_18 Private E-2

    This is where I think the error is at:

    while(($row = mysql_fetch_array($db))&&($i >= "0")) {

    You have quotes around the 0. I believe the problem is that you are comparing an integer with a string. If you remove the quotes it should work.
     
  3. CoreOxide

    CoreOxide Private E-2

    No...
    It's not it
     
  4. Mada_Milty

    Mada_Milty MajorGeek

    How many results does the SQL query return when run outside this script? (ie in a query analyzer tool)
     
  5. CoreOxide

    CoreOxide Private E-2

    Just one, from the first run.
    Like if I have a 3 row array, it will still return "1" and not "3".
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds