The below is the code of the PHP file that I creaed.
<?php
$db = mysqli_connect("127.0.0.1","root","toor","mylib")
or die('Error connecting to MySQL server.');
?>
<html>
<head>
</head>
<h1>PHP connect to MySQL</h1>
</body>
</html>
<?php
$query = "SELECT * FROM book WHERE bookid IN (SELECT bookid FROM studentbook WHERE studid =
$_POST['stuid'])";
mysqli_query($db, $query) or die('Error querying database.');
$result = mysqli_query($db, $query);
$row = mysqli_fetch_row($result);
foreach($row as $a)
print($a." ");
?>
Now, I am looking to get studid from HTML login page and passing it
to the PHP file using POST method to retrieve data corresponding to the value(studid) entered, from MySQL database - I mean using mysqli_query() function.
But when I try to run the code which I have shown above, I came up with below Error:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /opt/lampp/htdocs/connectivity.php on line 13
Please guide me on the following:
1) How to get values from Login page and pass it to the PHP file using post method?
2) How to correct the above mentioned error?