Results 1 to 3 of 3

Thread: PHP Help

  1. #1
    Senior Member
    Join Date
    Sep 2003
    Location
    London
    Posts
    255
    Thanks
    1
    Thanked
    0 times in 0 posts

    PHP Help

    I am getting the folowing error when this code is run:

    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/daniels/public_html/display.php on line 5

    From code:

    <?php
    include("connect.php");
    $query ="SELECT * FROM daniels_addresses";
    $result= mysql_query($query);
    $num=mysql_numrows($result);
    ?>
    <HTML>
    <table border="1" cellspacing="2" cellpadding="2">
    <tr>
    <th><font face="Arial, Helvetica, sans-serif">First Name</font></th>
    <th><font face="Arial, Helvetica, sans-serif">Surname</font></th>
    <th><font face="Arial, Helvetica, sans-serif">E-Mail</font></th>
    </tr>
    </HTML>

    <?PHP
    $i=0;
    while ($i<$num) {

    $FirstName =mysql_result($result,$i,"firstname");
    $LastName =mysql_result($result,$i,"lastname");
    $Email= mysql_result($result,$i,"email");
    $ID=mysql_result($result,$i,"id");
    ?>
    <HTML>

    <tr>
    <td><font face="Arial, Helvetica, sans-serif"><? echo "$firstname"; ?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><? echo "$lastname"; ?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><? echo "$Email"; ?></font></td>
    </TR>
    </HTML>
    <?PHP
    ++$i;
    }

    ?>


    I apologise if it is asimple mistake but I am still learning. I would apreciate any help.
    Specs:

    Q6600 G0, Thermalright Ultra 120, ABIT IP35 PRO, 4GB Corsair DDR2, Trusty old Tagan 480u, BFG 8800 GTS 512, Samsung F1 750 GB.

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

    Albert Einstein

  2. #2
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    $query ="SELECT * FROM daniels_addresses";
    $result= mysql_query($query);

    Change the bit above to

    $result = mysql_query("SELECT * FROM `daniels_addresses`");

    As it looks as if there's no point in making a variable for the "SELECT * FROM `daniels_addresses`" bit. Make sure spelling is correct and shorten down that table name

    I'm no SQL pro but that's just an idea.

  3. #3
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    it's mysql_num_rows not mysql_numrows

    The query should be fine as it is but if you still get the same error then it's because there's no data in daniels_addresses.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help, php masters!
    By Allen in forum Software
    Replies: 10
    Last Post: 07-07-2004, 07:16 AM
  2. PHP Tutorials
    By gss03 in forum Software
    Replies: 4
    Last Post: 09-05-2004, 12:09 PM
  3. adding php to w2k iis5?
    By joshwa in forum Software
    Replies: 13
    Last Post: 29-11-2003, 02:08 PM
  4. Creating databases using PHP?
    By Nemeliza in forum Software
    Replies: 10
    Last Post: 22-11-2003, 10:45 PM
  5. PHP and MySQL
    By Kezzer in forum Software
    Replies: 4
    Last Post: 28-10-2003, 02:59 PM

Posting Permissions

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