PDA

View Full Version : Error in php


shihan
May 4, 2009, 05:19 AM
I done a project. I write a following php script and create the mysql database.But I run the php file they show me error. What is the error

<?php
$con=mysql_connect("localhost","root");
if(!$con){
die('could not connect:'.mysql_error());
}

mysql_select_db("project",$con);

$sql="INSERT INTO customer(firstname)
VALUES ('$_POST[firstname]')";

if(!mysql_query($sql,$con));
{
die('Error.'.mysql_error());
}

echo"1 record added";
mysql_close($con)

?>

melissagirl
Jul 18, 2009, 02:18 AM
In the line:
Echo"1 record added";

Try adding a space between the word 'echo' and the quotation mark. If that's not it, please post the actual error message output by the PHP. If it doesn't set the error, try adding in:
Error_reporting(E_ALL);

So that it displays all errors.

rlerne
Oct 22, 2011, 10:42 PM
The last line of your code reads:


Mysql_close($con)

It should read:


mysql_close($con);

You're close, just missing a semicolon is all :)