...

View Full Version : PHP query problem?



firefighter25
05-17-2011, 07:59 AM
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in D:\Hosting\7186816\html\sites\hardwood\index.php on line 8

I am getting this message. Any idea why?


<?php
session_start();
require_once "scripts/connect_to_mysql.php";



// Determine which page ID to use in our query below

if (!$_GET['pid']) {
$pageid = '1';
} else {
$pageid = ereg_replace("[^0-9]", "", $_GET['pid']); // filter everything but numbers for

security
}
// Query the body section for the proper page
$sqlCommand = "SELECT pagebody FROM pages WHERE id='$pageid' LIMIT 1";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$body = $row["pagebody"];
}
mysqli_free_result($query);





// Query the module data for display

$sqlCommand = "SELECT modulebody FROM modules WHERE showing='1' AND name='footer' LIMIT 1";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$footer = $row["modulebody"];
}
mysqli_free_result($query);





// Query the module data for display

$sqlCommand = "SELECT modulebody FROM modules WHERE showing='1' AND name='custom1' LIMIT 1";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$custom1 = $row["modulebody"];
}
mysqli_free_result($query);





// Build Main Nav Menu and gather page data here

$sqlCommand = "SELECT id, linklabel FROM pages WHERE showing='1' ORDER BY id ASC";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());

$menuDisplay = '';
while ($row = mysqli_fetch_array($query)) {
$pid = $row["id"];
$linklabel = $row["linklabel"];

$menuDisplay .= '<a href="index.php?pid='. $pid . '">' . $linklabel . '</a></br>';

}

mysqli_free_result($query);


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Installing Hardwood Flooring - Self Install Flooring - Laying Flooring </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Description" content="How to Install Hardwood Flooring">
<meta name="KeyWords" content="Laying hardwood floors, why hardwood flooring, concrete">
<meta name="Author" content="John P">
<link rel=stylesheet href=style.css>
<!--[if lt IE 9]>
<script src=http://html5shiv.googlecode.com/svn/trunk/html5.js></script>
<![endif]-->
</head>



<body>
Hi
</body>

</html>

Fumigator
05-17-2011, 03:53 PM
Your variable $myConnection is null, not a valid mysqli resource. Check your connect_to_mysql.php script.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum