Log in

View Full Version : PHP alert help needed



batowiise
12-17-2010, 12:55 PM
Hi All,

I need help on implementing an alert using PHP and MySQL. The following is the plan:

1. User makes a requisition and the manager approves of it.

2. I want the manager to be alerted/notified of an impending requisition in the form of an alert.

The following is what i have done but it's not working:

<?php
require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users");
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>

Your help is welcome.

Regards.

Nile
12-17-2010, 12:59 PM
You aren't defining $row in that code - what error did you receive?

batowiise
12-17-2010, 01:08 PM
It just escaped me, i have modified the previous code to the following:

require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users where username='$uname'");
$row = mysql_fetch_array($result);
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>

Am still not getting the alert after defining the $row.

Regards

Nile
12-17-2010, 01:11 PM
Put or die(mysql_error()) after you're mysql functions. Is financealert 'Yes' in the first row returns by your query?

batowiise
12-17-2010, 01:33 PM
After placing the die(mysql_error()), the alert still did not come up. financealert 'Yes' is return by query in the database.

require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users");
$row = mysql_fetch_array($result);
die(mysql_error());
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>

Regards.

Nile
12-17-2010, 08:15 PM
<?php
require_once("admin/db.php");
$result = mysql_query("SELECT * FROM users where username='$uname'") or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
if($row['financealert'] == "Yes"){
?>
<script type="text/javascript">
alert('ATTENTION');
</script>
<?php
}
?>

bluewalrus
12-17-2010, 08:17 PM
Try


<?php
require_once("admin/db.php");
$result = @mysql_query("SELECT * FROM users");
$row = mysql_fetch_array($result);
die(mysql_error());
if($row['financealert']=='Yes'){
?>
<script type="text/javascript">
alert('ATTENTION');
</script>
<?php
echo "Got in the IF?";
}
?>

Nile
12-19-2010, 05:51 PM
Any updates?

batowiise
12-20-2010, 08:52 AM
Hi all,

I need the PHP code for the following scenario and this is the logic:

If user_session = username
and financealert == 'yes'
pop up an alert.

Your help is much needed.

Regards.

djr33
12-20-2010, 09:05 AM
You'll need to explain the details a lot more. If you have some code already, please post it. If not, how do you plan to determine those values? Where are they stored? What software are you using?
If you don't have anything (and you don't know how to do it) you may want to ask for paid help for someone to build a whole system for you.

batowiise
12-20-2010, 10:58 AM
The following is my code:

<?php
session_start();
$_SESSION['$username'];

require_once("admin/db.php");
$result = mysql_query("SELECT financealert, username FROM users WHERE financealert='yes'") or die(mysql_error());
if($user_session == $username && $financealert == 'yes') {
?>
<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<?php
}
?>

The alert is not showing anyway.

bluewalrus
12-20-2010, 02:26 PM
Please only have one thread per problem. What happened with the code I posted in the previous thread?

http://www.dynamicdrive.com/forums/showthread.php?t=59525

traq
12-21-2010, 01:54 AM
If you're still having trouble, something I noticed in the other thread you started is:

<script type="text/javascript">
windows.alert('ATTENTION');
</script>
<!-- should be: -->
<script type="text/javascript">
alert('ATTENTION');
</script>