Do not use on any
shared computer
September 6, 2008 01:26pm pdt
 
[x]
Attachment Details

Script works in FF but not IE7

Tags: php, javascript, Internet Explorer 7, Runtime Error: Expected Identifier, String or Number
Hi All,
I have searched countless fourms, many of which highlight a similar problem, alas, none of which provide an adequate solution. Apologies, if this question has indeed been answered already...

Basically, i am getting a rather frustrating runtime error in IE7 for the following script, which works perfectly well in Firefox. The script uses php to grab data from a remote mssql database and javascript to display this data in a datagrid.
The error message is as follows:
"Line:31 Error: expected Identifier, String or Number"

Which Indicates the error lies somewhere in the following piece of code:
<?php
  mssql_connect("UKSQLDEV2", "sa", "") or
  die("Could not connect: ");
  mssql_select_db("Logininfo") or die("No such DB Exists!  ");

 $task = '';
  if ( isset($_POST['task'])){
    $task = $_POST['task'];   // Get this from Ext
  }
  switch($task){
    case "LISTING":              // Give the entire list
      break;
    default:
      break;
  };
getlist();

function getList()
{
      $query = "SELECT * FROM tbllogininfo";
      $result = mssql_query($query);
      $nbrows = mssql_num_rows($result);           // Line 31

However, i just can't locate the problem. I'd be extremely grateful if someone could point me in the right direction.
The entire code is as attached:

Thanks in advance for your help,
David
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
<html>
<head>
    <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="extjs/ext-all-debug.js"></script>
        
    <script type="text/javascript">
Ext.onReady(function() {
	
	var myData = 
<?php
  mssql_connect("UKSQLDEV2", "sa", "") or
  die("Could not connect: ");
  mssql_select_db("Logininfo") or die("No such DB Exists!  ");
 
 $task = '';
  if ( isset($_POST['task'])){
    $task = $_POST['task'];   // Get this from Ext
  }
  switch($task){
    case "LISTING":              // Give the entire list
      break;
    default:
      break;
  };
getlist();
 
function getList() 
{
	$query = "SELECT * FROM tbllogininfo";
	$result = mssql_query($query);
	$nbrows = mssql_num_rows($result);	
	If ( $nbrows > 0)
		{
			while($rec = mssql_fetch_array($result))
				{ 
					$arr[] = $rec;
				}
			$jsonresult = JEncode($arr);
			echo $jsonresult;
		} 
	else 
		{
			echo '({"total":"0", "results":""})';
		}
};
 
function JEncode($arr){
    if (version_compare(PHP_VERSION,"5.2","<"))
    {    
        require_once("./JSON.php");   //if php<5.2 need JSON class
        $json = new Services_JSON();  //instantiate new json object
        $data=$json->encode($arr);    //encode the data in json format
    } else
    {
        $data = json_encode($arr);    //encode the data in json format
    }
    return $data;
}
?>
 
	var myReader = new Ext.data.ArrayReader({}, [
		{name: 'ID'},
		{name: 'Username'},
		{name: 'IP'},
		{name: 'Hostname'},
		{name: 'DateX'}
	]);
 
	var grid = new Ext.grid.GridPanel({
		store: new Ext.data.Store({
			data: myData,
			reader: myReader
		}),
		columns: [{header: 'ID', width: 30, sortable: true, dataIndex: 'ID'},
			{header: 'Username', width: 120, sortable: true, dataIndex: 'Username'},
			{header: 'IP', width: 100, sortable: true, dataIndex: 'IP'},
			{header: 'Hostname', width: 80, sortable: true, dataIndex: 'Hostname'},
			{header: 'Date', width: 75, sortable: true, dataIndex: 'DateX'}
		],
		viewConfig: {
			forceFit: true,
		},
		renderTo: 'content',
		title: 'Logins',
		width: 825,
		frame: true
	});
	grid.getSelectionModel().selectFirstRow();
	this.linkpage = function(grid, row, column, e) 
		{
			var humanFieldName = grid.colModel.getColumnHeader(column);
			var fieldName = grid.colModel.getDataIndex(column);
			var record = grid.store.getAt(row)
    	var b = record.get(fieldName);		
			window.open('http://ukit005/Link2.php?a='+b+'');
		}
		
    grid.on(
        'cellclick',
        this.linkpage      
//        function(this._grid, row, column, e) { }
    );
});
</script>
 
    <!-- Include Ext stylesheets here: -->
  <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"></link>
  <link rel="stylesheet" type="text/css" href="ExtStart.css"></link>
 
	
</head>
<body>
 
	<h1>Logininfo</h1>
 
	<br/>
	
    <div id='content'>
        
 
        
	</div>
</body>
</html>
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Software
Question Asked By: statpro
Solution Provided By: Tojiro
Participating Experts: 1
Solution Grade: B
Views: 29
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by Tojiro
Accepted Solution by Tojiro:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by statpro
Author Comment by statpro:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by Tojiro
Expert Comment by Tojiro:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by statpro
Author Comment by statpro:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628