SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A little help required please!

    Hi all, I'm having a spot of bother with some PHP/MySQL code, here it is:

    PHP Code:
    $query2 "SELECT * FROM $table";
    $result2 mysql_db_query($query2,$connection);
    while(list(
    $authname,$authmail,$authrate,$revtxt)=mysql_fetch_array($result2))
    {
    echo 
    "
    <table border=0 width=\"95%\" bgcolor=\"#666666\" border=0 cellpadding=3 cellspacing=0>
    <tr><td width=\"50%\" bgcolor=\"#0066FF\"><font face=arial size=-1 color=white><b>Reviewed by: <a href=\"mailto:authmail\">
    $authname</a></td><td width=\"50%\" bgcolor=\"#0066FF\"><p align=right><font face=arial size=-1 color=white><b>Rated: <img src=\"rating_$authrate.gif\" border=0 alt=\"Rated: $authrate\"></td></tr>
    <tr><td colspan=2><font face=arial size=-1 color=white>
    $revtxt</font></td></tr></table>
    "
    ;

    This is producing this error:

    Warning: Supplied argument is not a valid MySQL result resource in /usr/home/devilware/public_html/movies/reviews/view.php on line 62
    Line 62 is part of this code BTW. Any ideas? Thanks.

    -Sam
    Sam Hastings

  2. #2
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the error seems to be the mysql_db_query. it takes database, query and connection as parameters (see http://www.php.net/manual/en/functio...l-db-query.php). you're only providing query and connection (which would work with mysql_query, provided that you have used a mysql_select_db to select the proper database).

    PHP Code:
    $query2 "SELECT * FROM $table";
    $result2 mysql_query($query2,$connection); // changed
    while(list($authname,$authmail,$authrate,$revtxt)=mysql_fetch_array($result2))
    {
    echo 
    "
    <table border=0 width=\"95%\" bgcolor=\"#666666\" border=0 cellpadding=3 cellspacing=0>
    <tr><td width=\"50%\" bgcolor=\"#0066FF\"><font face=arial size=-1 color=white><b>Reviewed by: <a href=\"mailto:authmail\">
    $authname</a></td><td width=\"50%\" bgcolor=\"#0066FF\"><p align=right><font face=arial size=-1 color=white><b>Rated: <img src=\"rating_$authrate.gif\" border=0 alt=\"Rated: $authrate\"></td></tr>
    <tr><td colspan=2><font face=arial size=-1 color=white>
    $revtxt</font></td></tr></table>
    "
    ;

    btw, looking at your code i learnt something new...didn't know you could do that with list()=mysql_fetch_array construct...nifty

  3. #3
    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)
    BTW, you shouldn't be using mysql_db_query() since it's deprecated. use mysql_select_db() and then mysql_query().
    - 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


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
  •