php/mysql error message

Hello,

I'm getting this error message:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /homepages/28/d229406558/htdocs/index.php on line 98

the site is www.the3mediators.com

I've attached the home page code.

Thanks!
<?php
include('includeme.php');
$errors = array();
if (isset($_POST["name"]))
{
$_SESSION['name']=$_POST['name'];
if(isset($_POST['email'])) 
$_SESSION['email']=$_POST['email'];
 
if(isset($_POST['category'])) 
$_SESSION['category']=$_POST['category'];
 
if(isset($_POST['city'])) 
$_SESSION['city']=$_POST['city'];
 
if(isset($_POST['question'])) 
$_SESSION['question']=$_POST['question'];
 
if(empty($_SESSION['name']))
$errors[] = "Please enter your name";
 
if (!preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_SESSION['email']))
            {
               $errors[] = "Please enter valid email address.";
            }  
 
if(empty($_SESSION['city']))
$errors[] = "Please enter your city";
 
if(empty($_SESSION['question']))
$errors[] = "Please enter your question";
 
if (count($errors)==0)
{
header("Location:confirmation2.php");
exit();
}
}
?>
 
<html>
<head>
<title>The 3 Mediators</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<meta name="robots" content="index,follow" />
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
 
body {scrollbar-base-color:#9c2020;}
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; padding: 0; }
#AllContent { overflow: auto; padding: 10px; background: #eee; }
</style>
<script type="text/javascript">
 
function $(id) { return document.getElementById(id); }
 
function resize() {
   $('AllContent').style.height=(document.body.clientHeight-20)+'px';
}
 
window.onresize = resize;
window.onload = resize;
 
</script>
</head>
<body>
<div id="AllContent">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="284" height="18" id="MP3player" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="MP3player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="MP3player.swf" quality="high" bgcolor="#ffffff" width="284" height="18" name="MP3player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
 
<div id="container">
<div id="googletop">
<img src="images/googletop.gif">
</div>
<div id="header">
<img src="images/header.jpg">
</div>
<div id="one">
<ul class="menu">
<li class="menu"><a class="menu" href="index.php">Home</a></li>
<li class="menu"><a class="menu" href="archive.php?category=entertainment">Archives</a></li>
<li class="menu"><a class="menu" href="contact.php">Contact</a></li>
</ul>
<img src="images/googleleft.gif">
</div>
 
<div id="two">
<div id="welcome">
<?php
         $query3="SELECT welcome from pages";
         $result3= mysql_query($query3);
         $row3=mysql_fetch_array($result3);
         echo $row3[0];
?>
</div>
 
<form action="index.php" method="POST">
 
<?php
 
if (count($errors)>0)
{
   $error = implode("<br />", $errors);
   $error = "<span style=\"color:red;font-weight:bold;\">" . $error . "</span>";
   echo $error;
}
 
?>
<table style="color:#000000;background-color:#e7e7e7" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width:80px;text-align:left">&nbsp;&nbsp;Name:</td><td style="width:200px;text-align:left"><input type="text" name="name"></td>
</tr>
<tr>
<td style="text-align:left">&nbsp;&nbsp;Email:</td><td style="text-align:left"><input type="text" name="email"></td>
</tr>
<tr>
<td style="text-align:left">&nbsp;&nbsp;City:</td><td style="text-align:left"><input type="text" name="city"></td>
</tr>
<tr>
<td style="text-align:left">&nbsp;&nbsp;Category:</td><td style="text-align:left">
	<select name="category">
<option value="entertainment">Entertainment</option>
<option value="sports">Sports</option>
<option value="relationships">Relationships</option>
<option value="misc">Miscellaneous</option>
</select
></td>
</tr>
<tr>
<td colspan="2">Your Question:</td>
</tr>
<tr>
<td colspan="2"><textarea rows="20" cols="33" name="question"></textarea></td>
</tr>
<tr>
<td colspan="2" style="text-align:left"><input type="submit" name="submit" value="SUBMIT QUESTION"></td>
</tr>
</table>
</form>
 
</div>
 
<div id="three">
<br>
<strong style="color:#ffffff">Picks of the week:</strong>
<br>
<br>
<div id="three1">
<img style="margin-top:-10px;margin-left:-10px;margin-bottom:5px;margin-right:-10px;padding:0px" src="images/week1header.gif">
<?php
         $query3="SELECT week1 from pages";
         $result3= mysql_query($query3);
         $row3=mysql_fetch_array($result3);
         echo $row3[0];
?>
</div>
<br>
<br>
 
<div id="three2">
<img style="margin-top:-10px;margin-left:-10px;margin-bottom:5px;margin-right:-10px;padding:0px"" src="images/week2header.gif">
 
<?php
         $query3="SELECT week2 from pages";
         $result3= mysql_query($query3);
         $row3=mysql_fetch_array($result3);
         echo $row3[0];
?>
</div>
<br>
<br>
<div id="three3">
<img style="margin-top:-10px;margin-left:-10px;margin-bottom:5px;margin-right:-10px;padding:0px" src="images/week3header.gif">
<?php
         $query3="SELECT week3 from pages";
         $result3= mysql_query($query3);
         $row3=mysql_fetch_array($result3);
         echo $row3[0];
?>
</div>
</div>
 
<div id="googlebottom">
<img src="images/googletop.gif">
</div>
 
</div>
<?php include('footer.php'); ?>
</div>
</body>
</html>

Open in new window

LVL 7
weikelbobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
where do you connect to the database?
are you sure you select the correct db?

replace
         $result3= mysql_query($query3);

by
         $result3= mysql_query($query3) or die(mysql_error());

to see the error when running the query.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tomas Helgi JohannssonCommented:
    Hi!

Change line 98 to
$row3=mysql_fetch_array($result3,MYSQL_NUM);


Regards,
  Tomas Helgi
0
nplibCommented:
this
         $query3="SELECT welcome from pages";
         $result3= mysql_query($query3);
         $row3=mysql_fetch_array($result3);
         echo $row3[0];
is not how mysql_fetch_array() was intended for.
It's is for looping through to get the values from the database
         $query3="SELECT welcome from pages";
         $result3= mysql_query($query3);
         while ($row3=mysql_fetch_array($result3)) {
               echo $row3['0'];
        }

if you want to do it without looping

         $query3="SELECT welcome from pages";
         $result3= mysql_query($query3);
         $row3= mysql_result($result3, 0, "welcome");
         echo $row3;

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.