Hi Im new to this forum and new to php and currently working on a php for dummies book for my project I need to by March. I show you the problems
<?php
/* Program name: displayForm
* Descrption: Script displays a form that asks for
* the customer phone number
*/
?>
<html>
<head>
<title></title>
<style type='text/css'>
<!--
form {margin: 1.5em 0 0 0; padding: 0;}
.field{font-weight: bold; float: left; width: 20%; margin-right: 1em; text-align:right;}
#submit{margin-left: 35%; padding-top:1em;}
-->
</style>
</head>
<body>
<h3>Please enter your phone number </h3>
<form action='processform.php' method='POST'
<?php
//loop that displays the form fields
foreach($labels as $field => $label)
{
echo "<div class= 'field'>
<label for='$field'>$label</label>
<input type='text' name='$field' id='$field'
size='65' maxlength='65' /></div>\n";
}
echo"<div id='submit'><input type='submit' value='Submit Phone Number' />\n";
echo"</div>\n</form>\n</body>\n</html>";
?>
displays error
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\petstore\displayform.php on line 29
second error on another file im working on
<!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>Untitled Document</title>
</head>
<?php
require_once("config.php");
$type ="Horse";
$petInfo = getPetsOfType($type); //call function
/*Displays results in a table*/
echo "<h1>{$type}s</h1>\n";
echo "<table cellspacing='15'>\n";
echo "<tr><td colspan='4'><hr /></td></tr>\n";
for($i=1; $i<=sizeof($petInfo);$i++)
{
$f_price = number_format($petInfo[$i] ['price'], 2);
echo "<tr>\n
<td>$i.</td>\n
<td>{$petInfo[$i] ['petName']}</td>\n
<td>{$petInfo[$i] ['petDescription']}</td>\n
<td style='text-align: right'>\$$f_price</td>\n
</tr>\n";
echo"<tr><td colspan='4'> <hr /></td></tr>\n";
}
echo "</table>\n";
?>
<?php
function getPetsOfType($petType)
{
$j = 1;
while($row=mysqli_fetch_assoc($result))
{
foreach($row as $colname => $value)
{
$array_multi[$j] [$colname] = $value;
}
}
$j++;
}
return $array_multi;
?>
<body>
</body>
</html>
Error displays : Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\petstore\getpettype.php on line 43
I hope i made sense hope to hear from you peeps soon thanks :).