Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   PHP (https://www.askmehelpdesk.com/forumdisplay.php?f=454)
-   -   Error in php (https://www.askmehelpdesk.com/showthread.php?t=349474)

  • May 4, 2009, 05:19 AM
    shihan
    error in php
    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)

    ?>
  • Jul 18, 2009, 02:18 AM
    melissagirl
    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.
  • Oct 22, 2011, 10:42 PM
    rlerne
    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 :)

  • All times are GMT -7. The time now is 10:49 PM.