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.
You seem to be missing a " on this line: $result = mysql_query("SELECT * FROM mytable); It should be $result = mysql_query("SELECT * FROM mytable");
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.