[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

php/mysql error message

Posted on 2008-02-06
3
Medium Priority
?
337 Views
Last Modified: 2013-12-12
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

0
Comment
Question by:weikelbob
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 20830760
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
 
LVL 26

Expert Comment

by:Tomas Helgi Johannsson
ID: 20830766
    Hi!

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


Regards,
  Tomas Helgi
0
 
LVL 17

Expert Comment

by:nplib
ID: 20833155
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question