Jump to content

JS Mysql Alert box


jpergega
 Share

Recommended Posts

Hi

 

I am trying to create an alert box to connect to one of mysql table and the field is called "Finish", data type is Date.

When a task is expired I would like to have a popup message to alert the user to say the task is expired.

 

Here is the code which I am not able to get it to work is given me an error message, that is the code in red bold. I would be really grateful if someone can tell me what I'm doing wrong here please? Thanks

 

( ! ) Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:wampwwwScholarGoalTrackerstudentAccount.php on line 96

 

 

<?php
$curdate = date('m/d/y');
$query4 = 'select finish from task WHERE account_id =$account_id"';
$result4= mysqli_query($con, $query4);
while($row = mysqli_fetch_array($result4)){
if($row['finish'] == $curdate)
{
echo '<script language="javascript">alert("Your task had been expired.")</script>';
}
}

?>

Link to comment
Share on other sites

The query is wrong.

$account_id is literally being interpretted as "$account_id" because you've wrapped the string in single quotes. Aside from that, the double quote at the end of the string is a syntax error for MySQL. I don't see where the value of $account_id is being set, but you might be at risk of SQL injection.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...