12-28-2008
Fixed
Thanks Chris, but your fix didn't want to work either!
I've just discovered that my original format works fine as long as it's not embedded as a variable in a print quoted string, so maybe Chris's fix suffers from the same problem.
So this is broken...
print "First person is $person[$col[1]]";
...but this works...
print "First person is " . $person[$col[1]];
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am writing a BASH shell script. I have an array that will contain IN ANY ORDER the following elements: DAY 8D MO NS.
I would like to erase the element DAY, but since the order of the elements in the array are random, I will not know which element # DAY is (ie it's not as simple as... (3 Replies)
Discussion started by: msb65
3 Replies
2. Shell Programming and Scripting
Hi all,
I wanted to access two arrays (of same size) using one for loop.
Ex:
#!/bin/bash
declare -a num
declare -a words
num=(1 2 3 4 5 6 7)
words=(one two three four five six seven)
for num in ${num}
do
echo ":$num: :${words}:"
done
Required Output:
:1: :one: (11 Replies)
Discussion started by: 14341
11 Replies
3. Shell Programming and Scripting
Hi all
I have a file that i'm running and exec(cat ./dat) against..and putting its contents into any array, then doing an exploding the array into a multi-dimension array...
The 15 multi-dimensional arrays have elements that are null/empty, I would like to remove/unset these elements and then... (2 Replies)
Discussion started by: zeekblack
2 Replies
4. UNIX for Dummies Questions & Answers
Is there a way to print multiple array elements without iterating through the array using bash?
Can you do something like...
echo ${array}and get all those separate elements from the array? (2 Replies)
Discussion started by: jrymer
2 Replies
5. Shell Programming and Scripting
Hi,
I can't find out how to create correct code to get multiplication of each elements of array. Let's say I enter array into command line (2 3 4 5 6 8) and i need output 2*3*4*5*6*8=5760.
I tried this one, but answer is 0.
for i in $@; do
mult=$((mult*i))done
echo "mult: " $mult
... (4 Replies)
Discussion started by: rimasbimas
4 Replies
6. Shell Programming and Scripting
hello,
i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case
i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N.
for case 1, I want to stretch N to fit M
arrayHuge
H = (... (2 Replies)
Discussion started by: f77hack
2 Replies
7. Shell Programming and Scripting
Hi All,
need help with reading the array and sum of the array elements.
given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large.
Input Format
The first line of the input consists of an... (1 Reply)
Discussion started by: nishantrefound
1 Replies
8. Shell Programming and Scripting
I need your help to discover missing elements for each box.
In theory each box should have 4 items: ITEM01, ITEM02, ITEM08, and ITEM10.
Some boxes either have a missing item (BOX02 ITEM08) or might have da duplicate item (BOX03 ITEM02) and missing another one (BOX03 ITEM01).
file01.txt
... (2 Replies)
Discussion started by: alex2005
2 Replies
9. Shell Programming and Scripting
I'm looking for an efficient way to sum elements from 2 arrays using AWK and preserve header as well as sample names in the output array. I have Ubuntu 16.04 LTS. For example;
ARRAY 1
SAMPLE DERIVED ANCESTRAL
Sample1 14352 0
Sample2 14352 0
Sample3 14352 0
Sample4 ... (8 Replies)
Discussion started by: Geneanalyst
8 Replies
10. UNIX for Beginners Questions & Answers
So I need to Write an array processing program using a Linux shell programming language to perform the following.
Load array X of 20 numbers from an input file X.
Load array Y of 20 numbers from an input file Y.
Compute array Z by multiply Xi * Yi then compute the square-root of this... (2 Replies)
Discussion started by: sarapham409
2 Replies
LEARN ABOUT PHP
sqlsrv_errors
SQLSRV_ERRORS(3) SQLSRV_ERRORS(3)
sqlsrv_errors - Returns error and warning information about the last SQLSRV operation performed
SYNOPSIS
mixed sqlsrv_errors ([int $errorsOrWarnings])
DESCRIPTION
Returns error and warning information about the last SQLSRV operation performed.
PARAMETERS
o $errorsOrWarnings
- Determines whether error information, warning information, or both are returned. If this parameter is not supplied, both error
information and warning information are returned. The following are the supported values for this parameter: SQLSRV_ERR_ALL, SQL-
SRV_ERR_ERRORS, SQLSRV_ERR_WARNINGS.
RETURN VALUES
If errors and/or warnings occurred on the last sqlsrv operation, an array of arrays containing error information is returned. If no errors
and/or warnings occurred on the last sqlsrv operation, NULL is returned. The following table describes the structure of the returned
arrays:
Array returned by sqlsrv_errors
+---------+---------------------------------------------------+
| Key | |
| | |
| | Description |
| | |
+---------+---------------------------------------------------+
|SQLSTATE | |
| | |
| | For errors that originate from the ODBC driver, |
| | the SQLSTATE returned by ODBC. For errors that |
| | originate from the Microsoft Drivers for PHP for |
| | SQL Server, a SQLSTATE of IMSSP. For warnings |
| | that originate from the Microsoft Drivers for PHP |
| | for SQL Server, a SQLSTATE of 01SSP. |
| | |
| code | |
| | |
| | For errors that originate from SQL Server, the |
| | native SQL Server error code. For errors that |
| | originate from the ODBC driver, the error code |
| | returned by ODBC. For errors that originate from |
| | the Microsoft Drivers for PHP for SQL Server, the |
| | Microsoft Drivers for PHP for SQL Server error |
| | code. |
| | |
|message | |
| | |
| | A description of the error. |
| | |
+---------+---------------------------------------------------+
EXAMPLES
Example #1
functionname(3) example
<?php
$serverName = "serverName/sqlexpress";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
/* Set up a query to select an invalid column name. */
$sql = "SELECT BadColumnName FROM Table_1";
/* Execution of the query will fail because of the bad column name. */
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false ) {
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
?>
NOTES
By default, warnings generated on a call to any SQLSRV function are treated as errors. This means that if a warning occurs on a call to a
SQLSRV function, the function returns FALSE. However, warnings that correspond to SQLSTATE values 01000, 01001, 01003, and 01S02 are never
treated as errors. For information about changing this behavior, see sqlsrv_configure(3) and the WarningsReturnAsErrors setting.
SEE ALSO
sqlsrv_configure(3).
PHP Documentation Group SQLSRV_ERRORS(3)