😕 Hello
I am rather new to php and i have to create a library website, i am having the error
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Group\account.php on line 90
I know the problem is to do with my query as when i take the AND clause out it works
The code is below
<?php
$ID = $_GET['ID'];
if ($_GET["ID"] == "" ){
print "<p align=\"center\"><font color=\"red\"><b>Incorrect ID</b><br>Please enter the correct password</font></p>";
}
else {
# connect to MySQL
$conn=@mysql_connect("localhost", "root", "")
or die("Err:Conn");
# select the specified database
$rs=@mysql_select_db("library", $conn)
or die("Err:Db");
# select the specified database
$rs1=@mysql_select_db("library", $conn)
or die("Err:Db");
# create the query
$sql=("SELECT Student_ID, COUNT(Book_Borrowing_ID ) FROM loan WHERE Student_ID = ('$ID') GROUP BY Student_ID");
$sql1=("SELECT * FROM loan WHERE CURRENT_TIMESTAMP >= `Date_Due_Return` AND WHERE Student_ID = ('$ID') ");
# execute the query
$rs=mysql_query($sql,$conn);
$rs1=mysql_query($sql1,$conn);
# write the data
while( $row = mysql_fetch_array($rs) )
{
print "<p align=\"left\"><font color=\"black\"><b>Number of items on loan: ". $row['COUNT(Book_Borrowing_ID )'] ." </font></p>";
}
print "<head></head><body>
Books Overdue</b><p>";
print "<table border=0 bgcolor=#FFFFFF CELLSPACING=10> <tr><td>Book ISBN<td>Book Title<td>Date Loaned<td>Book Due Date</tr>";
# write the data
while( $row = mysql_fetch_array($rs1) )
{
$Book_ISBN=$row["Book_ISBN"];
$Book_Title=$row["Book_Title"];
$Date_Loaned=$row["Date_Loaned"];
$Date_Due_Return=$row["Date_Due_Return"];
print "<tr><td>$Book_ISBN<td>$Book_Title<td>$Date_Loaned<td>$Date_Due_Return</tr>";
}
print "</table></body>";
}
?>
MOD EDIT: [noparse]
..
[/noparse] bbcode tags added; please use these in the future when posting PHP code.