Page 1 of 1

My JavaScript not working.iUnsolved!

Posted: Mon Feb 20, 2006 10:13 pm
by JellyFish
When ever I move my mouse over the image it just says an error in the status bar.

Code: Select all

<?

//set two variables with the value of the database name and table name
$db_name = "";
$table_name = "";

//make a connection to the database
$connection = @mysql_connect("", "", "") or die(msql_error());

//set a variable to select a database I guess
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());


$sql_sel = "SELECT picture, webaddress FROM $table_name ORDER BY picture";
$result = @mysql_query($sql_sel,$connection) or die(mysql_error());

?>
<html>
<head>
<title>Home Page (example)</title>
<SCRIPT LANGUAGE="JavaScript">


//   ##############  SIMPLE  BROWSER SNIFFER
if (document.layers) {navigator.family = "nn4"}
if (document.all) {navigator.family = "ie4"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}

//  #########  popup text
descarray = new Array(
"This site has some of the greatest scripts around!",
);

overdiv="0";
//  #########  CREATES POP UP BOXES
function popLayer(a){
if(!descarray[a]){descarray[a]="<font color=red>This popup (#"+a+") isn't setup correctly - needs description</font>";}
if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
else {pad="1"; bord="0";}
desc = 	  "<table cellspacing=0 cellpadding="+pad+" border="+bord+"  bgcolor=000000><tr><td>\n"
	+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=ffffff><center><font size=-1>"
	+descarray[a]
	+"\n</td></tr></table>\n"
	+"</td></tr></table>";
if(navigator.family =="nn4") {
	document.object1.document.write(desc);
	document.object1.document.close();
	document.object1.left=x+15;
	document.object1.top=y-5;
	}
else if(navigator.family =="ie4"){
	object1.innerHTML=desc;
	object1.style.pixelLeft=x+15;
	object1.style.pixelTop=y-5;
	}
else if(navigator.family =="gecko"){
	document.getElementById("object1").innerHTML=desc;
	document.getElementById("object1").style.left=x+15;
	document.getElementById("object1").style.top=y-5;
	}
}
function hideLayer(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}

//  ########  TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;
//  End -->
</head>
<body>
<?
while ($row = mysql_fetch_array($result)) {

	$icon = $row['picture'];
	$webaddress = $row['webaddress'];
	$display_block .= "<a href=\"$webaddress\" onmouseover='popLayer(0)' onmouseout='popLayer()'><img src=\"http:///$icon\" width=20 height=20 border=0></a>";
}
?>
<? echo "$display_block"; ?>
</body>
</html></head>
<body>
<? echo "$display_block"; ?>
</body>
</html>
I don't know javascript just got this off the net but any help is appreciated.

EDITED: This script has been changed and what it does is it doesn't display any pictures. Why is this please help me I'd really really appreciate it.

Posted: Mon Feb 20, 2006 10:16 pm
by feyd
Moved to...... Client Side! wee. :?

Posted: Tue Feb 21, 2006 2:46 am
by phpScott
what is the error you are getting?

Posted: Tue Feb 21, 2006 3:17 am
by Chris Corbyn
http://www.w3style.co.uk/Javascript_Hig ... /phpdn.php

There's a trailing comma at the end of your array.
I'd also put the "var" keyword infront of descarray to ensure it's globally accessible.

Try using Firefox and open the JavaScript console from the tools menu.... much more useful debug info ;)

Posted: Tue Feb 21, 2006 8:44 pm
by JellyFish
What's the var keyword??? 8O Do you mean put var descarray = new Array( ..... ???