Would like to know why code has this result.
Warning: Supplied argument is not a valid MySQL result resource in /host/c/o/a/p/o/r/coaching4u.port5.com/mysql_php/event.php on line 20
Sorry, no records were found!
Does this mean that the CREATE TABLE event or INSERT INTO are still not working correctly?
<body>
<?php
$db = mysql_connect("localhost", "user", "pw");
$query = "CREATE TABLE event (
name VARCHAR(25),
date DATE NOT NULL,
type VARCHAR(15),
remark VARCHAR(255)
)";
$row = "INSERT INTO event VALUES (
('Fluffy', '1995-05-15', 'litter', '4 kittens', '3 female, 1 male') ,
('Buffy', '1993-06-23', 'litter', '5 puppies', '2 female, 3 male'),
('Buffy', '1994-06-19', 'litter', '3 puppies', '3 female'),
('Chirpy', '1999-03-21', 'vet', 'needed beak straightened'),
('Slim', '1997-08-03', 'vet', 'broken rib')
)";
mysql_select_db("coachin3",$db);
$result = mysql_query("SELECT * FROM event",$db);
if ($myrow = mysql_fetch_array($result)) {
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Type</tr>\n";
do {
printf("<tr><td>%s</td><td>%s</tr>\n", $myrow["name"], $myrow["type"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table>\n";
} else {
echo "Sorry, no records were found!";
}
mysql_close ($db);
?>
</body>