Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool MySQL in php attempted run error I don't understand?

    Working with Mint Linux and mySQL 5 and have ran into an error. I am connecting to the database, so I can rule out that aspect. Because it is a php code but a mysql error, I am posting here. --- If wrong, please correct me.

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/63/6793463/html/Sites/0-Testing/DDs.php on line 42

    The code that I am trying to run (php) is:

    <?php
    //Sample Database Connection Syntax for PHP and MySQL.
    //Connect To Database
    $host="WotCD.db.6793463.hostedresource.com";
    $uname="WotCD";
    $pass="xxxxxx";
    $dbname="WotCD";
    $usertable="Warships";

    $connection= mysql_connect ($host, $uname, $pass);
    if (! $connection) {
    die ("A connection to the Server could not be established!");
    } else

    // Setup heading and table
    echo "<br />";
    echo "DESTROYER LISTING";
    echo "<br />";
    mysql_select_db($dbname);
    $result = mysql_query('SELECT * FROM `Warships` WHERE `Type` = `DD` LIMIT 0, 30 ');

    echo "<table border='1'>
    <tr>
    <th>ID</th>
    <th>SHIP CLASS</th>
    <th>NAME </th>
    <th>CAT </th>
    <th>TYPE </th>
    </tr>";
    while($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['ID'] . "</td>";
    echo "<td>" . $row['SHIP CLASS'] . "</td>";
    echo "<td>" . $row['Name'] . "</td>";
    echo "<td>" . $row['CAT'] . "</td>";
    echo "<td>" . $row['TYPE'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";


    ?>

    I have a similar one based on another table - different fieilds, that works fine.
    Thanks in advance.

    Larry

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    PHP Code:
    WHERE `Type` = `DD
    Replace the back-ticks around DD with quote-marks. Also run the query in PHPMyAdmin or equivalent to ensure that there are matching records.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    WotCGM (11-11-2012)

  • #3
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    mysql/php error.

    Andrew,

    Thanks for the reply. That was all it was!

    Thanks Again

    Larry
    Last edited by WotCGM; 11-11-2012 at 02:21 AM. Reason: confirming other info posted by responder


  •  

    Tags for this Thread

    Posting Permissions

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