unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRIN

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

  1. #1
    When I am running my program it is giving following error -

    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\xampplite\htdocs\practice\sunil\showdata2.php on line 18

    my 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_arch","reset123");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $result = mysql_query("SELECT * FROM mytable);
    while($row = mysql_fetch_array($result))
    {
    echo $row['name'] . " " . $row['age'];
    echo "<br />";
    }mysql_close($con);
    ?>
    </body>
    </html>

    Please solve this error. Thanks.
     
    kharearch, Dec 18, 2007 IP
  2. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You seem to be missing a " on this line:

    $result = mysql_query("SELECT * FROM mytable);

    It should be

    $result = mysql_query("SELECT * FROM mytable");
     
    Kuldeep1952, Dec 18, 2007 IP
  3. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    My previous error is removed. But now when I am running my code it is giving following error -

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'sanganak_arch'@'localhost' (using password: YES) in E:\xampplite\htdocs\practice\sunil\showdata2.php on line 10
    Could not connect: Access denied for user 'sanganak_arch'@'localhost' (using password: YES)

    my 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_arch","reset123");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $result = mysql_query("SELECT * FROM mytable");
    while($row = mysql_fetch_array($result))
    {
    echo $row['name'] . " " . $row['age'];
    echo "<br />";
    }mysql_close($con);
    ?>
    </body>
    </html>


    I have given all privileges to my database.
     
    kharearch, Dec 18, 2007 IP