Hey I'm a beginner in mySQL, this is the code that i wrote,`
<?php
echo "Here is the table";
$con = mysql_connect("localhost","root","mypassword");
if(!$con)
die('Error:'.mysql_error());
// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE persons
(
f_name varchar(15),
l_ame varchar(15),
age int
)";
mysql_query("INSERT INTO persons (f_name, l_name, age)
VALUES ('Peter', 'Griffin', '35')");
mysql_query("INSERT INTO persons (f_name, l_name, age)
VALUES ('Glenn', 'Quagmire', '33')");
$res = mysql_query("SELECT * FROM persons");
while($row = mysql_fetch_array($res))
{
echo $row['f_name'] . " " . $row['l_name'];
echo "<br />";
}
?>`
I'm getting the following error
Here is the table Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/PhpProject1/index.php on line 40
why am I getting this error and how do I resolve it?