Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-10-2012, 08:59 PM   PM User | #1
WotCGM
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
WotCGM is an unknown quantity at this point
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
WotCGM is offline   Reply With Quote
Old 11-11-2012, 12:21 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
WotCGM (11-11-2012)
Old 11-11-2012, 02:20 AM   PM User | #3
WotCGM
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
WotCGM is an unknown quantity at this point
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
WotCGM is offline   Reply With Quote
Reply

Bookmarks

Tags
mysql, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21 AM.


Advertisement
Log in to turn off these ads.