$selectedCol=$row["selectedCol"];
     echo $selectedCol;
    $selectedColName=$row[$selectCol];   //<--- PLEASE NOTE THIS SPECIFIC
ROW

Please give me the output, what do you get from "echo $selectedCol;"? If I had to guess, it looks like you're confusing key and value of an associatative array.


if

$row["selectedCol"] = 12;

$row["12"] does NOT equal "SelectedCol".


In fact, even if you used mysql_fetch_array, you will not be able to do a reverse lookup like that.


Suppose you have the following :

$row['a'] = 1;
$row['b'] = 2;
$row['c'] = 1;

You can see that your approach is incorrect because what would $row[1] return?

If this is NOT your question, please post your output(errors and all).

----- Original Message ----- From: "Dale Hersowitz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 14, 2004 9:58 PM
Subject: [PHP] problem with array



Hi guys,
Recently, I had to reformat one of the web servers and now I have
encountered an unusual problem. I am not sure whether this is an issue which
can be fixed in the .ini file or whether its specific to the version of php
I am using.


Here is the problem:
  $query="SELECT * FROM customizeViewClients WHERE employeeNum =
$employeeNum";
  $results=mssql_query($query, $connection) or die("Couldn't execute
query");
  $numRows=mssql_num_rows($results);

   if($numRows>0)
  {
        $row=mssql_fetch_array($results);
   }

    $selectedCol=$row["selectedCol"];
     echo $selectedCol;
    $selectedColName=$row[$selectCol];   //<--- PLEASE NOTE THIS SPECIFIC
ROW


For some reason, on the last row, I am not unable to reference a particular
index in the array using a php variable. This has been working for almost 12
months and now the coding is breaking all over the place. I don't have an
answer. Any feedback would be greatly appreciated.


Thx.
Dale

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to