Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: PHP alert help needed

  1. #1
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP alert help needed

    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You aren't defining $row in that code - what error did you receive?
    Jeremy | jfein.net

  3. #3
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Put or die(mysql_error()) after you're mysql functions. Is financealert 'Yes' in the first row returns by your query?
    Jeremy | jfein.net

  5. #5
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    PHP Code:
    <?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
    }
    ?>
    Jeremy | jfein.net

  7. #7
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Try

    Code:
    <?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?";
    }
    ?>
    Corrections to my coding/thoughts welcome.

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Any updates?
    Jeremy | jfein.net

  9. #9
    Join Date
    Dec 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pop up alert

    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.

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •