SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I've got three checkboxes on which i want to search for results in my database. Code:
    ---------------------------
    if ($submit) {

    if ($webmail | | $opstartcd | | $telnet) {
    $sql = "SELECT * FROM access WHERE ";

    if ($webmail)
    {$sql .= "webmail = '$webmail ";}

    if ($opstartcd)
    {if ($webmail) $sql .= "AND ";
    $sql .= "opstartcd = '$opstartcd ";}

    if ($telnet)
    {if ($webmail | | $opstartcd) $sql .= "AND ";
    $sql .= "telnet = '$telnet ";}

    $result = mysql_query($sql);
    {
    echo "<table border=1>
    ";
    echo "<tr><td>Bedrijf</td><td>Pakket</td><td>Type</td><td>Regio</td></tr>
    ";
    while ($myrow = mysql_fetch_array($result)){
    printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>
    ",
    $myrow[bedrijf], $myrow[pakket], $myrow[type], $myrow[regio]);
    }}

    } else {
    echo("Oeps! None of the boxes selected.");
    }
    }
    ------------------------------------
    When i select a box and post the form i get the following error:

    Warning: Supplied argument is not a valid MySQL result resource in /opt/guide/www.webselect.nl/HTML/voorbeeld.php3 on line 30

    Line 30 is the following piece of code:
    while ($myrow = mysql_fetch_array($result))

    I don't see the problem. Do you?
    Great thanks,

    Joep

  2. #2
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see your problem, that error means that the query is failing and the reason is because you have missed a quote off of your queries: e.g. You have
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    {$sql .= "webmail = '$webmail ";}
    [/code]
    it should be:
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    {$sql .= "webmail = '$webmail' ";}
    [/code]

    ------------------
    Karl Austin
    KDA Web Services
    "Everyone has a photographic memory. Some just don't have film."

  3. #3
    SitePoint Member
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that was the problem. Stupid of me.
    Greeting from The Netherlands..

    Joep

  4. #4
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I'd already replied before I saw that the thread had been posted twice.

    ------------------
    Karl Austin
    KDA Web Services
    "Everyone has a photographic memory. Some just don't have film."


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
  •