Jump to content


Photo

script not working...


  • Please log in to reply
3 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 16 July 2006 - 09:02 PM

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:
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>';
			}


#2 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 16 July 2006 - 09:24 PM

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.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 17 July 2006 - 05:43 PM

What would <noscript> do? and how would I do this?

#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 17 July 2006 - 05:47 PM

The <noscript> tag

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users