SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jan 2002
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Help with this error

    Hi everyone. Need some help on this if possible

    I am getting this error!!!

    ------------------------
    Warning: 0 is not a MySQL result index in /u/web/mdnetc/mediaoutput_test.php3 on line 17

    There Were No Results for Your Search
    ------------------------------

    Can anyone explain what it means. Thanks in advance.

    Qamar
    *

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    Earth
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post the code?

    IT looks like you are trying to fetch results for a query that has no results.

    Frank
    http://www.serverexpert.com/ Discuss servers and the software that makes them work.
    http://www.webmasters-resources.com/ Resources for webmasters.

  3. #3
    SitePoint Addict
    Join Date
    Jan 2002
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi frank hope it makes sense. $type is a variable passed on from another form. I have also included the form code below.

    Thanks for looking into it

    Qamar


    PHP Code:
    mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
    @mysql_select_db("$DBName") or die("Unable to select database $DBName");
    $sqlquery = "SELECT * FROM $table WHERE medium = $type";
    $result = mysql_query($sqlquery);
    $number = mysql_numrows($result);

    $i = 0;

    if ($number < 1) {
    print"<CENTER><P>There Were No Results for Your Search</CENTER>";
    }
    else {
    while ($number > $i) {
    $medium = mysql_result($result,$i,"medium");
    $Name = mysql_result($result,$i,"Name");
    $Address = mysql_result($result,$i,"Address");
    $Tel = mysql_result($result,$i,"Tel");
    $Fax = mysql_result($result,$i,"Fax");
    $Email = mysql_result($result,$i,"Email");


    print "<p>
    <b>Medium:</b>
    $medium<br>
    <b>Name:</b>
    $Name<br>
    <b>Address:</b>
    $Address<br>
    <b>Telephone:</b>
    $Tel<br>
    <b>Fax:</b>
    $Fax<br>
    <b>";
    ?>

    <a href="mailto:

    <? echo "$Email";

     
    ?>

    ">E-mail</a>

    <hr>
    <?

    $i
    ++;
    }
    }
    ?>
    PHP Code:
    <html>
    <head><title> test button</title></head>
    <body bgcolor="#FFFFFF">
    <form name="form2" method="post" action="mediaoutput_test2.php3" >
      <select name="type">
        <?
    /* declare some relevant variables */
    $DBhost "host";
    $DBuser "user";
    $DBpass "password";
    $DBName "name";
    $type "type";

    mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");
    @
    mysql_select_db("$DBName") or die("Unable to select database $DBName");
    $sqlquery "SELECT*DISTINCT*medium*from*media";
    $result mysql_query($sqlquery);
    $number mysql_numrows($result);

    $i 0;

    if (
    $number 1) {
    print
    "<CENTER><P>There Were No Results for Your Search</CENTER>";
    }
    else {
    while (
    $number $i) {
    $medium mysql_result($result,$i,"medium");


    print 
    "<option value=\"$medium\">$medium</option>";


    $i++;
    }
    }
    ?> 
      </select>
      <input type="submit" name="Submit" value="Submit">
    </form>
    <p>&nbsp;</p>
    </BODY></HTML>

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the first thing you should always do when the query isn't working (which you know it's not b/c the result id isn't valid) is add "or die(mysql_error())" after mysql_query(). so, change

    $result = mysql_query($sqlquery);

    to

    $result = mysql_query($sqlquery) or die(mysql_error());

    then you'll see the problem. is $type text or a number? if it's text, then you need quotes around it, and that'll be the problem.

    another thing -- it's mysql_num_rows(), not mysql_numrows().
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2001
    Location
    Romania
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "0 is not a MySQL result index...". You initialized $i=0;

    Try replace it with:

    PHP Code:
    $i=1

  6. #6
    SitePoint Addict
    Join Date
    Jan 2002
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THANKS GUYS

    It worked a treat. I was also making a mistake where I was placing the variable at the top of the second php page like this

    PHP Code:
    $type "type"
    Thsi ment the data coming over from the other form was being changed to "type" .

    Make sense

    Anyway its working, I owe you one!


    Qamar


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •