I keep getting this error when trying to connect to my database any assistance would be helpful.
This is the database connect function
Code:
<?
function database_connect()
{
$dbhost = "mysql1.000webhost.com"; // Database host
$dbname = "a1863106_items"; // Database name
$dbusername = "a1863106_tar"; // Database user name
$dbuserpw = "hidden"; // Database password
mysql_pconnect($dbhost, $dbusername, $dbuserpw); //Connects to the mysql database area
$result = mysql_select_db($dbname); //Connects to the specific database and saves the result as result.
if (!$result)
return false; //Connected
else
return true; //not connected
}
?>
This is the webpage
Code:
<?
// start the session
session_start();
ob_start();
include ('includes/allfunctions.php');
header("Cache-control: private"); //IE 6 Fix
?>
<title>DDO Items</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<? include ('includes/header.php');
?>
</tr>
<tr>
<td height="500">
<?
//Connect to the database all fields are good so far
database_connect();
$sql = "SELECT * FROM 'DDO Items' WHERE 1";
while($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td>'.$row['ItemName'].'</td>';
echo '</tr>';
}
?>
</td>
</tr>
<td align="center" valign="bottom"><? include ('includes/footer.php')?>
</td>
</table>
</html>
This is the error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a1863106/public_html/gloves.php on line 22
Line 22 from above to help find it easier is:
PHP Code:
while($row = mysql_fetch_array($result)) {