SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict sedna's Avatar
    Join Date
    Jan 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql_fetch_array problem

    hey all,

    seem to be having an error

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\phpbb3hacks\hacks.php on line 72

    PHP Code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <table width="50%" border="0" cellspacing="0" cellpadding="3" align="left" >
    <tr>
    <th align="left">Hack Name</th>
    <th align="left">Description</th>
    <th align="left">Version</th>
    <th align="left">Author</th>
    <th align="left">Download</th>
    </tr>

    <?php
    include("config.php");

    // connect to the mysql server
    $link mysql_connect($server$db_user$db_pass)
    or die (
    "Could not connect to mysql because ".mysql_error());

    // select the database
    mysql_select_db($database)
    or die (
    "Could not select database because ".mysql_error());
    echo  
    "<h1> $hackname  </h1>";
    $search2=mysql_query("SELECT userid FROM users");
    $search=mysql_query("SELECT * FROM hacks WHERE `hacksid`={$_GET['hacksid']}");
    while(
    $result=mysql_fetch_array($search)){
    echo 
    '<h1>';
    echo 
    $hackname $result['hackname']  ;
    echo 
    '</h1>';
    echo 
    "<tr valign='top'>\n";
    $hacksid $result['hacksid'];
    $hackname $result['hackname'];
    $description $result['description'];
    $version $result['version'];
    $username $result['username'];


    echo 
    "<td>$hackname</td>\n";
    echo 
    "<td>$description</td>\n";
    echo 
    "<td>$version</td>\n";
    echo 
    "<td><a href='profile.php?userid=$username'>$username</a></td>\n";
    echo 
    "<td><a href='dload.php?hacksid=$hacksid'>Download</a></td>\n";
    echo 
    "</tr>\n";
    }
    ?>
    </table>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br /><h1>Status for <?php echo  "$hackname";?><br /></h1>
    <br />
    <table width="50%" border="0" cellspacing="0" cellpadding="3" align="left" >
    <tr>
    <th align="left">Downloads</th>
    <th align="left">Filesize</th>
    <th align="left">Date Added</th>
    </tr>
    <?php
    $sql2 
    mysql_query("SELECT * FROM hacks WHERE 'hacksid`={$_GET['hacksid']}");

    while(
    $result=mysql_fetch_array($sql2)){
    $count $result['count'];
    $size $result['size'];
    $dateadded $result['dateadded'];



    echo 
    "<td>$count</td>\n";
    echo 
    "<td>$size</td>\n";
    echo 
    "<td>$dateadded</td>\n";
    echo 
    "</tr>\n";

    }
    ?>
    </table>
    </body>
    </html>

  2. #2
    SitePoint Zealot dadofgage's Avatar
    Join Date
    Feb 2005
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it this line:

    $sql2 = mysql_query("SELECT * FROM hacks WHERE 'hacksid`={$_GET['hacksid']}");

    It looks like you have to replace the ' with a ` right after the WHERE statement.

  3. #3
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Also, after setting the query, you could write:
    Code:
    or die(mysql_error());
    which will give you a PHP error where the error could be.

  4. #4
    SitePoint Addict sedna's Avatar
    Join Date
    Jan 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    coll thanks guys, i never noticed that little ` that i missed off


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
  •