mysql/php query problem really bugging me
| From: | chip dot wiegand at simrad dot com | Date: | Tue, 06 Aug 2002 20:51:45 +0000 |
| Subject: | mysql/php query problem really bugging me | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-21018@lists.php.net to get a copy of this message | ||
I have a database and several tables on a mysql server maintained by my
ISP. I have set up another
mysql/php/apache server in my office. I have copied the database/tables/web
pages from the ISP's
server onto my server. Everything works great on my own server except the
queries to one particular
table. Here is the error I am getting:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in
/usr/local/apache/htdocs/bulletin_out.php on line 22
This same page works fine on the ISP's server, but my copy is not working
on my server.
--
Chip Wiegand
Computer Services
Simrad, Inc
www.simradusa.com
chip.wiegand@simrad.com
"There is no reason anyone would want a computer in their home."
--Ken Olson, president, chairman and founder of Digital Equipment
Corporation, 1977
(They why do I have 9? Somebody help me!)
Below is the code for the first page:
=================================
--html stuff here--
<?
include "connect";
if ($orderby == 'id'):
$sql = "select * from dbulletins order by 'news_id'";
elseif ($orderby == 'iddesc'):
$sql = "select * from dbulletins order by 'news_id' desc";
elseif ($orderby == 'vlad'):
$sql = "select * from dbulletins where bulletin_from1 like '%Vlad%' order
by 'bulletin_number' desc";
elseif ($orderby == 'burke'):
$sql = "select * from dbulletins where bulletin_from1 like '%Burke%' order
by 'bulletin_number' desc";
elseif ($orderby == 'hillers'):
$sql = "select * from dbulletins where bulletin_from1 like '%Hillers%'
order by 'bulletin_number' desc";
elseif ($orderby == 'parkinson'):
$sql = "select * from dbulletins where bulletin_from1 like '%Parkinson%'
order by 'bulletin_number' desc";
elseif ($orderby == 'trimble'):
$sql = "select * from dbulletins where bulletin_from1 like '%Trimble%'
order by 'bulletin_number' desc";
elseif (isset($submit)):
$sql = "select * from dbulletins where match (body) against ('%$search%')";
else:
$sql = "select * from dbulletins order by 'news_id' desc";
endif;
$result = mysql_query($sql);
while ( $row = mysql_fetch_array($result))
{
printf("<tr><td><font size='-1'>· <a
href='bulletin_out.php?news_id
=$row[news_id]'>%s</a> %s
<br /> %s</font></td></tr>",
$row["bulletin_subject"],
$row["bulletin_date"], $row["bulletin_from1"]);
}
?>
And here is the code for the second page:
=======================================
<?
if($news_id):
$query = "select * from dbulletins WHERE news_id='$news_id'";
endif;
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result))
{
if ($result):
{
print("<tr>\n<td colspan=\"2\">\n<img src=\"1pixb5e4f9.gif\"
alt=\"\"
height=\"20\" width=\"1\">\n</td>\n</tr>");
print("<tr>\n<td bgcolor=\"white\"
colspan=\"2\">\n<strong>\n");
printf("<font
color=\"blue\">%s</font>\n</strong>\n</td>\n</tr>\n", $row
["bulletin_number"]);
print("<tr>\n<td valign=\"top\">\n<h2
class=\"c1\">\n<br />Dealer
Bulletin</h2>");
printf("<strong>Date:</strong> %s\n", $row["bulletin_date"]);
printf("<br />\n<strong>Number:</strong> %s\n",
$row["bulletin_number"]);
printf("<br />\n<strong>Subject:</strong> %s\n",
$row["bulletin_subject"]);
printf("<br />\n<strong>From:</strong> %s<br />%s\n", $row
["bulletin_from1"], $row["bulletin_from2"]);
print("</td>\n<td valign=\"top\" align=\"left\">\n");
print("<font face=\"Arial Black\"
size=\"+6\">SIMRAD</font>\n");
print("<br />\n<font size=\"3\"> A
<strong>KONGSBERG</strong> Company</font>\n</center>\n");
print("<br />Simrad Inc.\n");
print("<br />19210-33<sup>rd</sup> Avenue West, Suite A\n");
print("<br />Lynnwood, WA 98036\n");
print("<br />U.S.A.\n");
print("<br />Telephone: 1-425-778-8821\n");
print("<br />Telefax: 1-425-771-7211\n");
print("<br />\n<br />\n</td>\n</tr>");
printf("<tr>\n<td colspan=2>%s\n", $row["body"]);
}
else:
printf("<tr><td>* %s</a><br /> %s<br
/>
%s</td></tr>", $row["bulletin_subject"],
$row["bulletin_from1"], $row
["bulletin_date"]);
endif;
}
?>