SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in C:\xamp

    Boy, this is so challenging to learn but so addictive. What am I doing wrong guys? the line is 17
    HTML Code:
    <?php?>
    <HTML><HEAD>
    <script type="text/javascript">
    var dateNow = new Date();
      var dayNow = dateNow.getDate();
      var showdate = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
    showdate.value = showdate;
    </script>
    </HEAD><body><br><script type="text/javascript">
    document.write(showdate);
    </script></body></html>
    PHP Code:
    <?php
    include("getinvno.php"); 
    mysql_connect(localhost,root,"");
    mysql_select_db(oodb) or die( "Unable to select database");
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    $query="SELECT payrec, ordernum, invnum, bname, bstreet, bcity, bstate, bzip, contact, sname, sstreet, scity, sstate, szip, terms, fob, shipdate, shipamt, dateord, datecomp, datepaid, qty, descr, charges, paidamt, tax, amtdue, paidsum FROM oocust WHERE payrec = 'R' AND pd = ' '";
     
    $result=mysql_query($query);
     if(
    mysql_num_rows($result))
     {
      while(list(
    $payrec$ordernum$invnum$bname$bstreet$bcity$bstate$bzip$contact$sname$sstreet$scity$sstate$szip$terms$fob$shipdate$shipamt$dateord$datecomp$datepaid$qty$descr$charges$paidamt$tax$amtdue$paidsum)= mysql_fetch_row($result))
      {
    echo 
    "Invoice No: $invnum<br />";
    echo 
    "Old Orchard Plumbing<br />2210 Hogan Hollow Road<br />Margate, Fl  33063<br /><br />"
    echo 
    "Bill To: <br />$bname<br />$bstreet<br />$bcity$bstate$bzip<br />";
    echo 
    "Contact is: $contact<br /><br />"
    echo 
    "Ship To: <br />$sname<br />$sstreet<br />$scity$sstate$szip<br /><br />"
    echo 
    "Terms: $terms<br />Due Date: $duedate<br />Fob: $fob<br />Ship Date: $shipdate<br />Order No: $ordernum<br /><br />"
    echo 
    "This bill is for: $qty $descr<br />Charges: $charges<br />tax=: $tax
    <br />Shipment Amt: 
    $shipamt<br />Amount Due: $amtdue<br /><br />"
    }
     }
     else{echo 
    "No listing for invoice No $invnum .<br />Please select another.<br />";}

    ?>
    HTML Code:
    <form method="post" action="#">We thank you for your business and timely payment
     <br />
     <input type="text" name="invnum"/> <p>
    <input type="submit" name="submit" value="+"/>
    </form>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    "Boolean given" usually means the SQL server didnt like your query and threw an error (FALSE) instead of a result set. Put
    PHP Code:
     $result=mysql_query($query);
     echo 
    mysql_error(); 
    and see what that tells you.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the response. the results the same. I should have told you, everything seems to work fine - just the message shows up.

  4. #4
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well , maybe its just me, but i see there two lines with mysql_numrows($result); in them.
    And in the first instance the $query is most likely would be .. emm .. empty.


    Which exactly is the line nr.17 in your code there ?
    Last edited by azazul; Apr 13, 2011 at 14:19. Reason: spelling mistakes

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you so much friend, boy I fought that one, now if I can figure out how put the date in. Once again, thanks
    HTML Code:
    <?php?>
    <HTML><HEAD>
    <script type="text/javascript">
    var dateNow = new Date();
      var dayNow = dateNow.getDate();
      var showdate = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
    showdate.value = showdate;
    </script>
    </HEAD><body><br><script type="text/javascript">
    document.write(showdate);
    </script></body></html>
    PHP Code:
    <?php 
    include("getinvno.php");  
    mysql_connect(localhost,root,""); 
    mysql_select_db(oodb) or die( "Unable to select database"); 
    // $result=mysql_query($query); 
    // $num=mysql_numrows($result); 
    $query="SELECT payrec, ordernum, invnum, bname, bstreet, bcity, bstate, bzip, contact, sname, sstreet, scity, sstate, szip, terms, fob, shipdate, shipamt, dateord, datecomp, datepaid, qty, descr, charges, paidamt, tax, amtdue, paidsum FROM oocust WHERE payrec = 'R' AND pd = ' '";
    $result=mysql_query($query);  
    if(
    mysql_num_rows($result))  
       {
    while(list(
    $payrec$ordernum$invnum$bname$bstreet$bcity$bstate$bzip$contact$sname$sstreet$scity$sstate$szip$terms$fob$shipdate$shipamt$dateord$datecomp$datepaid$qty$descr$charges$paidamt$tax$amtdue$paidsum)= mysql_fetch_row($result))
       { 

    // echo "Date: $showdate<br />";
     
    echo "Invoice No: $invnum<br />"
    echo 
    "Old Orchard Plumbing<br />2210 Hogan Hollow Road<br />Margate, Fl  33063<br /><br />";  
    echo 
    "Bill To: <br />$bname<br />$bstreet<br />$bcity$bstate$bzip<br />"
    echo 
    "Contact is: $contact<br /><br />";  echo "Ship To: <br />$sname<br />$sstreet<br />$scity$sstate$szip<br /><br />";  
    echo 
    "Terms: $terms<br />Due Date: $duedate<br />Fob: $fob<br />Ship Date: $shipdate<br />Order No: $ordernum<br /><br />";  
    echo 
    "This bill is for: $qty $descr<br />Charges: $charges<br />tax=: $tax <br />Shipment Amt: $shipamt<br />Amount Due: $amtdue<br /><br />";
      }
      }  
    ?>

  6. #6
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Incidentally you dont really need the num_rows check - a WHILE loop on an empty set will simply not execute.


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
  •