error in code

Discussion in 'PHP' started by kharearch, Dec 28, 2007.

  1. #1
    It is showing following error on execution of my program

    Parse error: syntax error, unexpected T_VARIABLE in /home/sanganak/public_html/dwarka_parichay_copy/add.php on line 18


    my program code is following

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $s = $_POST['name']
    $p="mohan";
    echo $s;
    echo $p;
    if($s == $p)
    {
    header('Location:http://sanganak.co.in/dwarka_parichay_copy/useful_links.htm');
    }
    mysql_close($con)
    ?>
    </body>
    </html>

    Please solve my error in code. Thanks.
     
    kharearch, Dec 28, 2007 IP
  2. yourihost

    yourihost Well-Known Member

    Messages:
    1,708
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    115
    #2
    Replace it with

    You forgot the ;
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");
    
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $s = $_POST['name'];
    $p="mohan";
    echo $s;
    echo $p;
    if($s == $p)
    {
    header('Location:http://sanganak.co.in/dwarka_paricha...nks.htm');
    }
    mysql_close($con)
    ?>
    </body>
    </html>
    PHP:
     
    yourihost, Dec 28, 2007 IP
  3. wdstuff54

    wdstuff54 Well-Known Member

    Messages:
    639
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    110
    #3
    yourihost is right. The line that was messed up was $s = $_POST['name'] it should be $s = $_POST['name'];
     
    wdstuff54, Dec 28, 2007 IP
  4. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you also missing a ; after mysql_close($con)

    should be

    mysql_close($con);
     
    lfhost, Dec 28, 2007 IP