hi there is anything wrong with the code down here....?

<?
@mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("upit");

$sql="INSERT INTO students VALUES('$nama','$ic','$fakulti','$emel')";
$result=mysql_query($sql);
if ($result)
echo"Insert record Successfully";

else
echo "Problem inserting data";
?>

Recommended Answers

All 3 Replies

What is the error ?

if ($result)
echo"Insert record Successfully";

else
echo "Problem inserting data";


you have no braces included with if ...
try this

if ($result) {
echo"Insert record Successfully";
}
else {
echo "Problem inserting data"; }

It doesn't matter if there is only 1 statement in the condition. But, its a good practice to use braces :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.