CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   MySQL in php attempted run error I don't understand? (http://www.codingforums.com/showthread.php?t=281839)

WotCGM 11-10-2012 08:59 PM

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

AndrewGSW 11-11-2012 12:21 AM

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.

WotCGM 11-11-2012 02:20 AM

mysql/php error.
 
Andrew,

Thanks for the reply. That was all it was! :thumbsup:

Thanks Again

Larry


All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.