xyn Posted July 16, 2006 Share Posted July 16, 2006 Hey,I have a PM system and wanted to alert any user if they receive a new PM whilst somewhere else on the site. I attached my code into the sessions which is on every page it doesn't work.I had a new Pm and it wouldn't alert me:[code=php:0]include "db.php"; $ssql = mysql_query("SELECT * FROM pm WHERE sendto='{$_SESSION['user']['user']}' AND stats='0'"); $numb = @mysql_num_rows($ssql); if( $numb > 0 ) { echo '<script>alert("You have got a new Private message")</script>'; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14793-script-not-working/ Share on other sites More sharing options...
pixy Posted July 16, 2006 Share Posted July 16, 2006 You could try something like...$query = "SELECT COUNT(*) FROM pm WHERE sendto='{$_SESSION['user']['user']}' AND stats='0'";$result = mysql_query($query);if (mysql_num_rows($result) != 0) { echo '<script>alert("You have got a new Private message")</script>';}Question: Why do you have $_SESSION['user']['user']? Why don't you use use $_SESSION['user']?And, some people disable javascript so your alert wouldn't do anything anyways. You can put <noscript> tags around an alternate message for people who turn it off. That way, they would be notified even if they have javascript turned off. Quote Link to comment https://forums.phpfreaks.com/topic/14793-script-not-working/#findComment-59077 Share on other sites More sharing options...
xyn Posted July 17, 2006 Author Share Posted July 17, 2006 What would <noscript> do? and how would I do this? Quote Link to comment https://forums.phpfreaks.com/topic/14793-script-not-working/#findComment-59518 Share on other sites More sharing options...
Orio Posted July 17, 2006 Share Posted July 17, 2006 [url=http://www.w3schools.com/tags/tag_noscript.asp]The <noscript> tag[/url]Orio. Quote Link to comment https://forums.phpfreaks.com/topic/14793-script-not-working/#findComment-59521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.