Skip to main content
Typo
Source Link
Asciant
  • 2.2k
  • 1
  • 15
  • 26

You don't need the error checking at the end of the $sql var:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0')" or die( 'mysql_error()' );

It is a statement, thus there is nothing it can or die on fail. Try changing it to the following:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0');"

Not sure if its necessarily the cause of your error, but it isn't required no the less.

Also I ran your code minus the header redirect and as mentioned by nickhornenickohrn you need to connect to the mysql server before using mysql_real_escape_string. The code worked fine, locally the record was into the database.

Try running your code without the header() call.

You don't need the error checking at the end of the $sql var:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0')" or die( 'mysql_error()' );

It is a statement, thus there is nothing it can or die on fail. Try changing it to the following:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0');"

Not sure if its necessarily the cause of your error, but it isn't required no the less.

Also I ran your code minus the header redirect and as mentioned by nickhorne you need to connect to the mysql server before using mysql_real_escape_string. The code worked fine, locally the record was into the database.

Try running your code without the header() call.

You don't need the error checking at the end of the $sql var:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0')" or die( 'mysql_error()' );

It is a statement, thus there is nothing it can or die on fail. Try changing it to the following:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0');"

Not sure if its necessarily the cause of your error, but it isn't required no the less.

Also I ran your code minus the header redirect and as mentioned by nickohrn you need to connect to the mysql server before using mysql_real_escape_string. The code worked fine, locally the record was into the database.

Try running your code without the header() call.

Source Link
Asciant
  • 2.2k
  • 1
  • 15
  • 26

You don't need the error checking at the end of the $sql var:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0')" or die( 'mysql_error()' );

It is a statement, thus there is nothing it can or die on fail. Try changing it to the following:

$sql = "INSERT INTO $tbl_name(usuario, comentario, fecha, estado) VALUES('$usuario','$falla','$fecha', '0');"

Not sure if its necessarily the cause of your error, but it isn't required no the less.

Also I ran your code minus the header redirect and as mentioned by nickhorne you need to connect to the mysql server before using mysql_real_escape_string. The code worked fine, locally the record was into the database.

Try running your code without the header() call.