FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Warning: mysql_fetch_array() expects parameter 1 to be resou





jpsmy81
HI Guys....I need some help. i'm newbe for phpmysql.

i have home page called home, which contains hyperlink to other pages, 1 such page is searchagency.php. when i hit this page the warning as below

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\strateq\searchagency.php on line 113

but

im able to do search, where when i select my option in dropbox and hit search the i got the resualt and the warning will automatically disappear

please help me i have due date for this project.

thank you
jpsmy81
sourcecode for home.php

<?php
session_start();
include_once 'dbconnect.php';


if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['email']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
<style type="text/css">
.auto-style1 {
margin: 5px 4px;
}
</style>
</head>
<body>
<div id="header">
<div id="left">
<label></label>
</div>
<div id="right">
<div id="content">
hi' <?php echo $userRow['username']; ?>&nbsp;<a href="logout.php?logout">Sign Out</a>
</div>
</div>
<img alt="" class="auto-style1" height="36" src="images/strateq.jpg" style="float: left" width="218" />
</div>

<div id="body">
<a href="searchagency.php">Search Agency</a><br />
<a href="addagency.php">Add Agency</a><br />
<a href="vmconfig.php">Server Configuration</a><br />
<a href="searchagency.php">Manage Servers</a><br />


</div>
</body>
</html>

sourcecode for searchagency.php

<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);

$aname = "SELECT * FROM agency";
$result = mysql_query($aname);

$searchservers = false;
if(isset($_POST['submit'])){
$agency_code=$_POST['agency_code'];
//-query the database table
$sql = "SELECT * FROM vmservers WHERE agency_code LIKE '%" . $agency_code . "%'";
$searchservers = mysql_query($sql);
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GDC2:Online Agency Library System Welcome Your're - <?php echo $userRow['email']; ?></title><!--
<link rel="stylesheet" href="style1.css" type="text/css" />-->
<link rel="stylesheet" href="style2.css" type="text/css" />
<style type="text/css">
.auto-style1 {
margin: 5px 4px;
}
</style>
</head>
<body>
<div id="header">
<div id="left">
<label></label>

</div>
<div id="right">
<div id="content">
hi' <?php echo $userRow['username']; ?>&nbsp;<a href="logout.php?logout">Sign Out</a>
</div>
</div>
<img alt="" class="auto-style1" height="36" src="images/strateq.jpg" style="float: left" width="218" />
</div>
<p>GDC2:Online Agency Library System : </p>
<div id="vmconfig-form">

<table border="0">
</table>

</div>
<br />
<a href="home.php">Main Page</a>

<form method='POST' >
<table border="0">

<tr>
<td style="width: 112px">
<p>Select Agency :</p>
</td>
<td style="width: 113px">

<?php
echo "<select style='width:150px' required name='agency_code'>";
echo "<option>--Select Agency--</option>";
while ($row = mysql_fetch_array($result)) {
$agencycode=$row["agency_code"];
$agencyname=$row["agency_name"];
echo "<option VALUE='$agencycode'>$agencyname</option>";
}
echo "</select>";
?>
</td>
<td>
<input type="submit" name="submit" value="Search" />
</td>
</tr>

<tr bgcolor="#149508">
<td>Agency Code</td>
<td>Server Type</td>
<td>System Name</td>
<td>VM Name</td>
<td>Server Name</td>
<td>Virtual vCPU</td>
<td>Virtual vRam</td>
<td>Provisioned Storage</td>
<td>Operating System</td>
<td>Application</td>
<td>Database</td>
<td>Internal Server IP</td>
<td>GiTN IP</td>
<td>Public IP</td>
<td>FQDN</td>
<td>Virtualized</td>
<td>StandByStatus</td>
<td>Location</td>
<td>RTO</td>
<td>RPO</td>
<td>Recovery Solution</td>
<td>Schedule</td>
<td>Backup Type</td>
</tr>

<?php
while($row = mysql_fetch_array($searchservers))
{
echo ("<tr><td>$row[agency_code]</td>");
echo ("<td>$row[a_servertype]</td>");
echo ("<td>$row[a_systemname]</td>");
echo ("<td>$row[a_vmname]</td>");
echo ("<td>$row[a_servername]</td>");
echo ("<td>$row[a_vcpu]</td>");
echo ("<td>$row[a_vram]</td>");
echo ("<td>$row[a_vhdd]</td>");
echo ("<td>$row[a_os]</td>");
echo ("<td>$row[a_application]</td>");
echo ("<td>$row[a_database]</td>");
echo ("<td>$row[a_internalip]</td>");
echo ("<td>$row[a_gitnip]</td>");
echo ("<td>$row[a_publicip]</td>");
echo ("<td>$row[a_fqdn]</td>");
echo ("<td>$row[a_virtulize]</td>");
echo ("<td>$row[a_status]</td>");
echo ("<td>$row[a_location]</td>");
echo ("<td>$row[a_rto]</td>");
echo ("<td>$row[a_rpo]</td>");
echo ("<td>$row[a_solution]</td>");
echo ("<td>$row[a_schedule]</td>");
echo ("<td>$row[a_type]</td>");
//echo ("<td><a href=\"edit_form.php?id=$row[agency_code]\">Edit</a></td></tr>");
}
?>

</table>
</form>

</body>
</html>[/img]
sonam
Before line
Code:
while ($row = mysql_fetch_array($result)) {


you haven't valid SQL statement.

Only if you using this from lines:
Code:
$aname = "SELECT * FROM agency";
$result = mysql_query($aname);


But I am not sure are this working in this way.

Sonam
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.