1 Replies - 7883 Views - Last Post: 30 August 2010 - 12:01 PM Rate Topic: -----

#1 gymangel812  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 116
  • Joined: 15-February 10

Warning: mysqli_query() expects parameter 1 to be mysqli, null given

Posted 30 August 2010 - 11:56 AM

I'm getting the following errors in my page and i don't know why:
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\Program Files\IndigoPerl\apache\htdocs\uvgc\includes\header.html on line 180

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\Program Files\IndigoPerl\apache\htdocs\uvgc\includes\header.html on line 182

Warning: mysqli_close() expects parameter 1 to be mysqli, null given in C:\Program Files\IndigoPerl\apache\htdocs\uvgc\includes\header.html on line 204

header.html (which is included in index.php)
<?php # Script 17.2 - header.html

// Start output buffering and initialize a session.
ob_start();
session_start();

?>
<!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>Ultimate Video Game Connection</title>
<link rel="stylesheet" media="all" type="text/css" href="css/styles.css" />
<style type="text/css">
<!--
body,td,th {
	color: #080C58;
}
-->
</style></head>

<body>
<div id="outer">
<div id="nav_bar"><img src="images/header1.jpg" width="950" height="107" alt="logo" />
  <div class="container">
    <ul class="nav">
		<li><a href="index.php">Home</a></li>
	</ul>
	<ul class="nav">
		<li class="sub-li"><a class="sub-a" href="#url">Nintendo</a>
			<ul>

				<li><a href="browse_nes.php">NES</a></li>
				<li><a href="browse_snes.php">Super Nintendo (SNES)</a></li>
				<li><a href="browse_n64.php">Nintendo 64</a></li>
				<li><a href="browse_gb.php">Game Boy</a></li>
				<li><a href="browse_gbc.php">Game Boy Color</a></li>
				<li><a href="browse_gc">Gamecube</a></li>
				<li><a href="browse_gba">Game Boy Advance (GBA)</a></li>
				<li><a href="browse_ds.php">DS</a></li>
				<li><a href="browse_wii.php">Wii</a></li>
				<li><a href="browse_vb.php">Virtual Boy</a></li>
			</ul>
		</li>
	</ul>
    	<ul class="nav">
		<li class="sub-li"><a class="sub-a" href="#url">Microsoft</a>
			<ul>

				<li><a href="browse_xbox.php">Xbox</a></li>
				<li><a href="browse_360.php">Xbox 360</a></li>
			</ul>
		</li>
	</ul>
    	<ul class="nav">
		<li class="sub-li"><a class="sub-a" href="#url">Sony</a>
			<ul>

				<li><a href="browse_ps1.php">Playstation 1</a></li>
				<li><a href="browse_ps2.php">Playstation 2</a></li>
				<li><a href="browse_ps3.php">Playstation 3</a></li>
			</ul>
		</li>
	</ul>
        <ul class="nav">
		<li class="sub-li"><a class="sub-a" href="#url">Sega</a>
			<ul>

				<li><a href="browse_genesis.php">Genesis</a></li>
				<li><a href="browse_dc.php">Dreamcast</a></li>
				<li><a href="browse_segacd.php">Sega Cd</a></li>
				<li><a href="browse_saturn.php">Saturn</a></li>
			</ul>
		</li>
	</ul>
    	<ul class="nav">
		<li class="sub-li"><a class="sub-a" href="#url">Other</a>
			<ul>

				<li><a href="browse_pc.php">PC</a></li>
				<li><a href="browse_ngcd.php">Neo Geo CD</a></li>
				<li><a href="browse_pce.php">PC Engine</a></li>
				<li><a href="browse_tg16.php">Turbo Grafx 16</a></li>
				<li><a href="browse_tgcd.php">Turbo Grafx CD</a></li>
			</ul>
		</li>
	</ul>
	    	<ul class="nav">
		<li class="sub-li"><a class="sub-a" href="#url">About</a>
			<ul>

				<li><a href="about.php">About Us</a></li>
				<li><a href="faq.php">FAQ</a></li>
			</ul>
		</li>
	</ul>
        <ul class="nav">
		<li><a href="contact.php">Contact</a></li>
	</ul>
            <ul class="nav">
		<li><a href="view_cart.php">View Cart</a></li>
	</ul>


</div></div><br />
<div id="main_content">
<table width="875" border="0" cellspacing="2" cellpadding="5">
  <tr valign="top">
  <td width="35%" valign="top">
  <div id="xsnazzy">
<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
<div class="xboxcontent">
<h2>Enter A Game Name to Search</h2>
<center><p>
<form method="post" action="search.php">
                        <input type="text" name = "select_name" id="search" class="search_box_font" value="Search for a game!" onfocus="if (this.value == 'Search for a game!') this.value = '';" onblur="if (this.value == '') this.value = 'Search for a game!';" maxlength="255" />
            <input type="image" class="button" src="images/btn_search.png" />
          </form></p>
</div>
<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b></center>
</div>

<div id="xsnazzy">
<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
<div class="xboxcontent">
<p>
<?php
// Welcome the user (by name if they are logged in).
if (isset($_SESSION['username'])) {
    echo '<h2>Welcome, ';
	echo "{$_SESSION['username']}!</h2>";
	$username=$_SESSION['username'];
	//query for the position
	require_once ('mysqli_connect.php');

	$q="SELECT user_position, username FROM users WHERE username='$username'";
	$r = mysqli_query ($dbc, $q);
	$row = mysqli_fetch_array ($r, MYSQLI_ASSOC);
	if($row['user_position'] == "admin"){
		echo '<p><br /><a href="logout.php">Logout</a>';
		echo '<br /><a href="select_names.php">Send Email to Selected Users</a>';
	}
	else {
		echo '<p><br /><a href="logout.php">Logout</a>';
		echo '<br /><a href="change_password.php">Change Your Password</a>';
		echo '<br /><a href="discount.php">Available Coupons</a>';
		}
	}
else {
        echo '<h2>Welcome, Guest ';
	echo '<br /><a href="login.php">Click here to sign in</a> ';
	echo '<br /><a href="add_user.php">Click here to register</a> ';
}
?> </p>


</p>
</div>
<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
</div>

  <div id="xsnazzy">
<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
<div class="xboxcontent">
<center><p>
<h2>Recent Updates</h2>
<?php
$searchNotFound  = false;

// Update selection query
$q = "SELECT title, link, description, recorddate
          FROM feed
          ORDER BY recorddate DESC
		  LIMIT 3;";

// Create the table head:
//echo '<table border="0" cellspacing="2" cellpadding="4" width="90%">';

// Display updates
$result = mysqli_query ($dbc, $q);
 // If the result is not empty
    $num_results = mysqli_num_rows($result);

  if( $num_results ) {
		while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {

			// Display each record:
			echo "<p>{$row['title']}</p>
				<p>\${$row['description']}</p>
				<p><a href=\"{$row['link']}\">Click here to view entire story</a></p>";


		} // End of while loop.

      // Free up the resources.
      mysqli_free_result($result);

    } else {
      // wanted string not found - set not found flag on true
      $searchNotFound  = true;
    }

    // Close the database connection.
    mysqli_close($dbc);

if( $searchNotFound ) {
        echo '<p>No updates yet.</p>';
}
?>
Subscribe to our feed:<br>
<a href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open('http://www.seocentro.com/cgi-bin/promotion/bookmark-rss/rss.pl?u='+c( 'http://www.DEVELOPMENT-DESIGNS-BY-SARA.com/uvgc/feed.xml' ),'bookmark_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=480px,width=720px,scrollbars=1,resizable=1,alwaysRaised=1');a.setTimeout(function(){ d.focus()},300)})();" title="Social Bookmark"><img src="http://www.seocentro.com/bookmark-rss/images/rss_button02.gif" alt="RSS Feed Readers" border="0" title="RSS Feed Readers"></a>
</p>
</div>
<b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b></center>
</div>

</td>
    <td width="65%"><center>


Is This A Good Question/Topic? 0
  • +

Replies To: Warning: mysqli_query() expects parameter 1 to be mysqli, null given

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: Warning: mysqli_query() expects parameter 1 to be mysqli, null given

Posted 30 August 2010 - 12:01 PM

Please learn to read your error messages. This is line 180:
$result = mysqli_query ($dbc, $q);

what is parameter 1? Why would it be NULL?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1