RE: [PHP] problem with array
| From: | Graham Cossey | Date: | Fri, 15 Oct 2004 07:39:24 +0000 |
| Subject: | RE: [PHP] problem with array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199564@lists.php.net to get a copy of this message | ||
> 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
[snip]
Note because you used $selectCol instead of $selectedCol?
I would also move the } to after this line so that you do not attempt to
access non-existent array elements when no rows are returned.
HTH
Graham