I'm new to PHP, and I keep getting errors with this line:
$query2 = "insert into student(regno, name) values('100', 'abc')";
I think I've got the syntax correct, but I'm not sure.
The error given is:
Parse error: syntax error, unexpected T_LNUMBER in C:\wamp\www\mydb2.php on line 7
The rest of my code is:
$con = mysql_connect("localhost", "root", "");
mysql_select_db("mydb", $con);
$query1 = "create table student(
regno int primary key,
name varchar(10) NOT NULL)";
$query2 = "insert into student(regno, name) values('100', 'abc')";
if(result1 = mysql_query($query1, $con))
{
echo "table created";
}
if(result2 = mysql_query($query2, $con))
{
echo "insert successfull";
}
while(mysql_fetch_rows(result2))
{
echo "<table><th>regno</th><th>name</th>";
echo "<tr><td>regno[0]</td><td>name[0]</td></tr></table>";
}
mysql_close($con);