Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a page where the user searches for records after typing a keyword in a textbox and clicks on a button. However I am getting an error saying "Division by zero in C:\wamp\www\admin-rights-display.php on line 77" and "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\admin-rights-display.php on line 93". I dont know what to do. Here are my codes:
PHP
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Community Night Cycling 2014 Singapore</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0,user-scalable = no">
    <meta name="googlebot" content="index, follow" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta name="author" content="" />
    <link rel="stylesheet" href="style/general.css" />
    <link rel="stylesheet" href="style/framework.css" />
    <link rel="stylesheet" href="style/site.css" />
    <script src="js/modernizr-2.0.6.min.js" type="text/javascript"></script>
</head>
<body class="contact">
    <div class="mother">
        <header class="mast-head stack-fixed clearfix">
			
			<article class="logo">
				<a href="index.html"></a>
			</article>
			
			<nav class="main-nav">
			
				<ul>
					<li class="first">	
						<a href="home.html">Home</a>
					</li>
					
					<li>
						<a href="register.html">Registration</a>
					</li>
                    
                    <li>
						<a class="selected" href="admin.html">Administrator Page</a>
					</li>
                    
					
					<li class="last">	
						<a href="stats.html">Statistics</a>
					</li>
				</ul>
				
			</nav><!-- end .main-nav -->
			
		</header>
        <article class="main" role="main">
<section class="stack-fixed clearfix entry-text">
	<div class="top-mast contact-top-mast">

	</div>
		
	
	<div class="row">
            	
                <div class="slat-8">
                   
                   
                    <div id="fields">
                    					$Search = $_POST['Search'];
					if ($Search == "ALL")
					{
						$result = mysql_query("SELECT Name, Gender, Age, Email, Occupation, NRIC, Address, ZipCode FROM members ",$connection);
					}
					else
					{
						$result = mysql_query("SELECT Name, Gender, Age, Email, Occupation, NRIC, Address, ZipCode FROM members WHERE Address LIKE '.$Search."%"'",$connection);
					}
					
					echo "<table border="1">
					<tr>
					<th>Name</th>
					<th>Gender</th>
					<th>Age</th>
					<th>Email</th>
					<th>Occupation</th>
					<th>NRIC</th>
					<th>Address</th>
					<th>ZipCode</th>
					
					</tr>";
					
					while($row=mysql_fetch_array($result))
					{
						echo"<tr>";
						echo"<td".$row['name'].">";
						echo"<td".$row['gender'].">";
						echo"<td".$row['age'].">";
						echo"<td".$row['email'].">";
						echo"<td".$row['occupation'].">";
						echo"<td".$row['nric'].">";
						echo"<td".$row['address'].">";
						echo"<td".$row['zipcode'].">";
						echo "</tr>";
					}
					echo "</table>";
					mysql_close($connection);
						?>
                    </div>
                </div>
     </div>
</section>



<section class="stack-fixed entry-text footer clearfix">
	
	
	<ul class="slat-7 first">

	</ul>

	<ul class="slat-3">
		
                                <li><i class="icon-envelope"></i> <a href="#">awesome@egrappler.com</a></li>
                                <li><i class="icon-retweet"></i> <a href="https://twitter.com/charitycycle13">Connect on Twitter</a></li>
                                <li><i class="icon-share-alt"></i> <a href="https://www.facebook.com/WondersOfTheWorldCharityCycle">Share With Your Friends</a></li>
                                <li><i class="icon-question-sign"></i> Help</li>
      
		
	</ul>
    
    
     <ul class="slat-2 last">
		
		
				<li><a href="home.html">Home</a></li>
				<li><a href="register.html">Registration</a></li>
                <li><a href="admin.html">Administrator Page</a></li>
                <li><a href="stats.html">Statistics</a></li>
		
		
	</ul>
	
</section>	




		</article>
    </div>
    <!-- end .mother -->
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script defer src="js/accessories-min.js" type="text/javascript"></script>
    <script defer src="js/site.js" type="text/javascript"></script>
    <!--[if lt IE 7 ]>
	<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
	<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
	<![endif]-->

</body>
</html><?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Community Night Cycling 2014 Singapore</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0,user-scalable = no">
    <meta name="googlebot" content="index, follow" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta name="author" content="" />
    <link rel="stylesheet" href="style/general.css" />
    <link rel="stylesheet" href="style/framework.css" />
    <link rel="stylesheet" href="style/site.css" />
    <script src="js/modernizr-2.0.6.min.js" type="text/javascript"></script>
</head>
<body class="contact">
    <div class="mother">
        <header class="mast-head stack-fixed clearfix">
			
			<article class="logo">
				<a href="index.html"></a>
			</article>
			
			<nav class="main-nav">
			
				<ul>
					<li class="first">	
						<a href="home.html">Home</a>
					</li>
					
					<li>
						<a href="register.html">Registration</a>
					</li>
                    
                    <li>
						<a class="selected" href="admin.html">Administrator Page</a>
					</li>
                    
					
					<li class="last">	
						<a href="stats.html">Statistics</a>
					</li>
				</ul>
				
			</nav><!-- end .main-nav -->
			
		</header>
        <article class="main" role="main">
<section class="stack-fixed clearfix entry-text">
	<div class="top-mast contact-top-mast">

	</div>
		
	
	<div class="row">
            	
                <div class="slat-8">
                   
                   
                    <div id="fields">
                    					$Search = $_POST['Search'];
					if ($Search == "ALL")
					{
						$result = mysql_query("SELECT Name, Gender, Age, Email, Occupation, NRIC, Address, ZipCode FROM members ",$connection);
					}
					else
					{
						$result = mysql_query("SELECT Name, Gender, Age, Email, Occupation, NRIC, Address, ZipCode FROM members WHERE Address LIKE '.$Search."%"'",$connection);
					}
					
					echo "<table border="1">
					<tr>
					<th>Name</th>
					<th>Gender</th>
					<th>Age</th>
					<th>Email</th>
					<th>Occupation</th>
					<th>NRIC</th>
					<th>Address</th>
					<th>ZipCode</th>
					
					</tr>";
					
					while($row=mysql_fetch_array($result))
					{
						echo"<tr>";
						echo"<td".$row['name'].">";
						echo"<td".$row['gender'].">";
						echo"<td".$row['age'].">";
						echo"<td".$row['email'].">";
						echo"<td".$row['occupation'].">";
						echo"<td".$row['nric'].">";
						echo"<td".$row['address'].">";
						echo"<td".$row['zipcode'].">";
						echo "</tr>";
					}
					echo "</table>";
					mysql_close($connection);
						?>
                    </div>
                </div>
     </div>
</section>



<section class="stack-fixed entry-text footer clearfix">
	
	
	<ul class="slat-7 first">

	</ul>

	<ul class="slat-3">
		
                                <li><i class="icon-envelope"></i> <a href="#">awesome@egrappler.com</a></li>
                                <li><i class="icon-retweet"></i> <a href="https://twitter.com/charitycycle13">Connect on Twitter</a></li>
                                <li><i class="icon-share-alt"></i> <a href="https://www.facebook.com/WondersOfTheWorldCharityCycle">Share With Your Friends</a></li>
                                <li><i class="icon-question-sign"></i> Help</li>
      
		
	</ul>
    
    
     <ul class="slat-2 last">
		
		
				<li><a href="home.html">Home</a></li>
				<li><a href="register.html">Registration</a></li>
                <li><a href="admin.html">Administrator Page</a></li>
                <li><a href="stats.html">Statistics</a></li>
		
		
	</ul>
	
</section>	




		</article>
    </div>
    <!-- end .mother -->
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script defer src="js/accessories-min.js" type="text/javascript"></script>
    <script defer src="js/site.js" type="text/javascript"></script>
    <!--[if lt IE 7 ]>
	<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
	<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
	<![endif]-->

</body>
</html>
Posted
Updated 2-Feb-14 0:40am
v2
Comments
Richard MacCutchan 2-Feb-14 7:13am    
I dont know what to do.
1. Look at the source code lines as mentioned in the two error messages.
2. Identify where in your code you are calling into the modules that give the error.
3. Provide those full details in your question.
Maarten Kools 2-Feb-14 7:33am    
mysql_query[^] will return False on an error, so either one of your select queries is incorrect. Hint: Balance your quotes in queries.

1 solution

Your sql statement was not well-formed, so it has mistaken % as modulus division and caused first error
change
LIKE '.$Search."%"'"

to
LIKE '".$Search."%'"

Once this is resolved, the 2nd error will go away.

I have also discovered other syntax errors, for example:
change
echo"<td".$row['name'].">";

to
echo"<td>".$row['name']."</td>";

do the same for the other tr tags.

These are as far as I can see. Good luck.
Btw, you have pasted your code twice.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900