Programming :: PHP MySQL Array Return Unexpected Data

Nov 8, 2010

I am trying to build an array with the column headers and the data like so:

PHP Code:
function query($query) {
$data = array();
$q = "$query";
$this->log->message("Manual query [$q], returning columns...");
$result = @mysqli_query($this->dbc, $q);
$this->selected_rows = mysqli_num_rows($result);

while($meta = mysqli_fetch_field($result)) {
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "meta [{$meta->name}]"; $data[$meta->name][] = $row[$meta->name]; } }
echo "DATA ["; print_r($data); echo "] <br />";
return $data; }

So I can select the data from the array like so:
PHP Code:
echo $data[col_name][row_num];

However when I dump the array I dont get the data I am expecting:
Code:
running select * from users:
meta [company_name]meta [company_name]
DATA [Array ( [company_name] => Array ( [0] => My company [1] => My details ) ) ]

View 6 Replies


ADVERTISEMENT

Programming :: Error: Unexpected Array Reference At (1)

Sep 30, 2010

read(224,114)inum(i,j),jnum(i,j),dx(i,j),dy(i,j),h(i,j),
1
Error: Unexpected array reference at (1)

View 2 Replies View Related

Programming :: Debian Serial Port Read() Return Wrong Data?

Jul 6, 2010

I am implementing a simple serial protocol where my ARM9 board, running Linux is communicating to a slave peripheral board. The Master sends a 12 byte data stream and the peripheral board returns status in a 23 byte response. The serial port is opened in raw mode. It works perfectly on 44 reads; however, on the 45 read the data returned from the read() is incorrect. I've framed what's being sent on an oscope and it is correct.The coincidence is that 23 x 44 = 1012. It's as though the receive buffer is 1K and when I go past the boundary I get bad data. The read following the bad one is good again.I've tried flushing the buffer before reading but get the same result.Here's the port initialization code:

Code:
int initport(int fd)
{

[code]...

View 4 Replies View Related

Programming :: Send A Mysql Query Output Into An Array?

Jul 27, 2010

i will be quick, im trying to send a mysql query output into an array ie:

Code:
declare -a HD
HD=`echo "USE db; SELECT uid FROM user" | mysql -u $login -p$pwd -h $dbhost -B`
echo ${#HD}
those vars in mysql connection are previously and correctly assigned.
but got an error

script.sh: 2: declare: not found

View 3 Replies View Related

Programming :: Bash To Loop Through Mysql Select Array?

May 26, 2011

I need to know how to assign a result from a select. I am clueless on the sytax. I am trying this in bash. Maybe I am not assigning the array right. It gives me the whole row in the echo instead of just field a. How do I get fieldA = a in the select. Note script was stripped for security on database info but the syntax is same.

Code:

#!/bin/sh
results="$(mysql --user ${DB_USER} -p${DB_PWD} ${DB_NAME} -Bse 'select a,b,c,d from tblMytable')"
for rows in "${results[@]}"
do
fieldA=${rows[0]};
echo ${fieldA};
done

View 2 Replies View Related

Ubuntu Multimedia :: XDisplayHeightMM() Return Unexpected Value?

Aug 4, 2011

I'm using XDisplayHeightMM function from X11/Xlib.h, on one machine and it returns 203,while another machines returns 41351.why the second machine returns such a bigger value? does it have to do with the configuration?

View 1 Replies View Related

Programming :: Comparing Data In Array In FORTRAN?

May 16, 2010

I have two arrays of data, called data1.dat and data2.dat. each contains 60 data. What I want to do is to compare the data in each file and write the counting into bins. It goes like this. First, take the first data in data1.dat file and compare with the 60 data in data2.dat file. If there is any data which is same with the data in data1.dat then it count in bin. The total bins are also 60. Next it goes to the second data in data1.dat and compare with all the 60 data in data2.dat. If there is any data same then it add in second bin. And it repeats to all the data in data1.dat

View 3 Replies View Related

Programming :: Reading A File Of Data In An Array?

Feb 10, 2011

I have two files of data with different numbers of columns and rows. I want to read this two files in two arrays and then compare for example the second column of first data file with the third column of the other text file and if the difference between of two numbers is less than a threshold then the program print the information in the rows which fulfill this condition in the third text file. I have written below program but the problem is that it does not go through all rows of second file.

declare -a a
declare -a b
r=` awk '{n++} END {print n}' second.txt `
echo $r
awk '
{

[Code]....

Actually I have two data files one of them contains 44406 and the other one has 12066 rows and I want to check whether the difference between the components of two specific columns is less than a threshod but I have simplified it here. I had written this code and then I have realized that this code just goes through the number of rows as the same as the first.txt file and ignores the rest. I could not find the problem yet.

View 2 Replies View Related

Programming :: Writing Shell Snip To Import CSV Data Into Bash Array

Jan 5, 2011

I have been trying to write a simple snip of bash shell code to import from 1 to 100 records into a Bash array.

I have a CSV file that is structured like:
record1,item1,item2,item3,item4
record2,item1,item2,item3,item4
record3,item1,item2,item3,item4
record4,item1,item2,item3,item4

And would like to get this data into corresponding arrays as such:
$record1[item1-4]
$record2[item1-4]
$record3[item1-4]
$record4[item1-4]

View 9 Replies View Related

Programming :: MySQL - Get A Random Selection Of An Ordered Data Set

Jan 11, 2011

Given the following data structure: Quote:

[Code]...

What is the minimum possible MySQL query to get a random data selection that includes each Index number only once and ordered ascending. The maximum index number is known. For example running the query should get the following data: 01, 06, 07, 02. Running the query again, you may get the same data or another possible combination like: 01, 05, 07, 04. Of course you could run a loop for 1 to max_index and process a random ordered data selection until the next index number is found. But I think this will result in too many database access. Also you could run max_index queries to get all IDs that correspond to the given index and randomly select one ID for each index.

View 3 Replies View Related

Programming :: Automating Data Entry Into MySQL Database?

Jul 19, 2010

I have set up a MySQL database which has only three fields for user-name, password and index number. But there is a LOT of data (thousands of columns) which would take too long to enter manually. I'm sure MySQL must have a file format whereby a single large file containing different data types can be successfully automatically imported and the various data elements distributed to their intended fields. Does anyone know which characters MySQL uses as field seperators for this formatting of data, or is there a program already written which can take raw data and organize it into a SQL compatible file?

View 8 Replies View Related

Programming :: Translate Data From A CSV File To A MySQL Database?

Aug 26, 2010

I have a CSV called source1 with data like:

Date12:00:00 AM12:30:00 AM01:00:00 AM01:30:00 AM02:00:00 AM02:30:00 AM03:00:00 AM ...
07/31/1051.5252.4852.6452.863.3663.8445.6 ...
08/01/1049.4449.9261.2860.1652.6449.1247.52 ...
08/02/1049.1248.9648.9650.7260.1658.0851.04 ...
08/03/1060.3260.6459.260.9637.9233.2832.8 ...

[Code].....

Also, the CSV file is updates every few hours and I need to load any new data from the file to the database without creating duplicates of data that has already been loaded to the database.

View 6 Replies View Related

Programming :: Perl: Compare CGI Input With Data From A MySQL Table?

Nov 19, 2008

I have this program:

#! /usr/bin/perl
use DBI ;
use strict ;

[code]....

and I get this error simply running the program from the command line: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at ./submit.cgi line 24.

is this the right syntax to use, both, for this line:

my (@param) = $cgi->param("firstname","lastname","type") ;

as well as this one:

$sth=$dbh->prepare ("SELECT firstname,lastname,type FROM dts WHERE firstname LIKE $param[0] AND lastname LIKE $param[1] and type LIKE $param[2]" );

or should there be quotes around the $param[0] or something? (also is it $param[0] or $param(0)?)

View 1 Replies View Related

Programming :: Python - Get Text File Data Into An Array On Python?

Nov 30, 2009

I've already used line split stuff to transform my data into something like this in a text file:

Code:

['1', '1', '3', '20.7505207']
['2', '1', '3', '23.0488319']
['3', '1', '3', '-1.5768747']
['4', '1', '3', '-26.4772491']

[code]....

How can I get this on a python program so I can manipulate it as an array?

View 3 Replies View Related

General :: Split A String Into Array In Bash Return Wrong Size?

Mar 21, 2011

I'm trying to split a string, to later iterate using a for loop like

Code:
for (( i=0; i<5; i++))

But, my script returns an array with the size 1.

Here's the script:

Code:
aver=$(grep "avg" A.txt | awk '{ print $2 }');
a=$(echo $aver | tr " " "
");

[Code]....

View 2 Replies View Related

Programming :: C Realloc Resize Array / Delete And Add Information Into The Array?

Mar 6, 2011

I am trying to dynamically delete and add information into the array "blah"

Code:
int blahsize = 1;
char** blah = (char**) calloc(blahsize+1,sizeof(char*));
Adding information:
Code:
blah[1]=stuff1;
blah[2]=stuff2;
code....

View 2 Replies View Related

Programming :: Convert Short Array To Char Array?

Jun 7, 2010

I have trouble converting a short array to a char array

Code:

short pShort[4] = { 0x41, 0x42, 0x43, 0x44 };

How to convert this to a char array?

View 4 Replies View Related

Programming :: Converting A PHP Array Into An HTML Array?

Aug 9, 2009

I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.

echo '<input type="hidden" name="delete[]" value="'.$_POST['delete'].'" />';

View 4 Replies View Related

Ubuntu :: Unable To Return Calendar Data From External Source

Feb 19, 2010

Using AWN 0.3.9 on Ubuntu 9.10. AWN calendar applet returns the message "Unable to return calendar data from external source" when started. It is configured to read Evolution which is functioning normally.

View 4 Replies View Related

Programming :: Filling 2D Array With 1D Array In C?

May 26, 2010

(I am using vector() and matrix() functions from "Numerical recipes in C".)There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.100 numbers are stored in a 1D array.I get "segmentation fault" at the line indicated in the segment of my code below:

Code:

:
:
#define size 100
#define nl 1

[code]....

View 12 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Programming :: Termios Programming - Without Removing Carriage Return / Enter Key

Jun 30, 2010

I trying to write a UART(interfacing of serial devices) to linux machine but after I execute the following code to receive data I need to enter key (carriage return).... but I don't want to remove carriage return/enter key

[Code]....

View 13 Replies View Related

OpenSUSE Hardware :: Recovering MySQL Db From Failed RAID Array

Jun 30, 2011

I recognize that this isn't the typical question, but I have a problem with my OpenSUSE webserver, and I thought I would prevail on the community for some guidance. I have this webserver with an important MySQL db on it. The RAID array seems to have died while I was moving. (did someone drop it? dunno) Now it can't find any boot device. It has 4 old SCSI drives.

So, I know how to mount a IDE or SATA drive as a slave, in a Linux environment to read data off of it (to copy the MySQL files off of it.) But, how do I do that with a SCSI drive? Also, I have an additional (identical) server to the crippled one. What will happen if I just slide one of the scsi drives into the operating server? Is this second identical server going to help me at all? I don't even know what is on it. Can I reconfigure the RAID, so it's not using a drive, and then slide in a disk from the crippled server, and copy the data off of it?

View 2 Replies View Related

Programming :: Sed - Syntax Error Near Unexpected Token

Mar 9, 2011

#by executing bash file
#!/bin/sh
sed -i 's/if (IEexec || domExec) document.write('<iframe id="IdMyIframe" '+IframePropriedades+'></iframe>');//g' *.php

Output is:
line 4: syntax error near unexpected token `<'
line 4: 'sed -i 's/if (IEexec || domExec) document.write('<iframe id="IdMyIframe" '+IframePropriedades+'></iframe>');//g' *.php'

View 6 Replies View Related

Programming :: Syntax Error Near Unexpected Token

Jun 18, 2010

I'm fairly new to shell scripting and am having the hardest time figuring out why this simple script is giving me an error

The error is "syntax error near unexpected token `else'

I'm using TextEdit on OSX (sorry I'm limited to this). The only thing I can think of is that it's reading some return character and getting thrown off. I've tried saving the script using different encoding types but the same error pops up.

I also get an error at line 2 because it does not regonize as a command

View 5 Replies View Related

Software :: Recovering Data From MD Array (using Knoppix)

Jun 2, 2011

I had a major OS crash (Gentoo) maybe 2 months ago and completely neglected my system. Now I want to recover all my mirror raid data back so that I can restore the system. My plan is this:

1) copy all data so that I can have a backup
2) rebuild system with some HW upgrades

First step is to get the data out. I managed to boot with Knoppix and I have full access to my ext2 partitions. My mistake was to create the mirror partitions and these are not working now. I copied my /etc/mdadm.conf into /etc/mdadm/mdadm.conf in Knoppix and then tried to start the services. This is what I got:

knoppix@Microknoppix:~$ /etc/init.d/mdadm start
knoppix@Microknoppix:~$ /etc/init.d/mdadm-raid start
Assembling MD arrays...failed (failed to load MD subsystem).

I can see the partitions:

[Code]......

These are my current ideas:

1) Can I change the filesystem type from mdraid to ext2 or ext3 safely?

2) How can I mount these raid filesystems so that I can copy my data?

View 2 Replies View Related

Programming :: Syntax Error Near Unexpected Token - Not Working ?

Jan 28, 2010

I got this script from website for inviting peoples to game and earning points easily ...but this seems not working and giving error..

View 4 Replies View Related

Programming :: YACC Syntax Error Unexpected Identifier

Feb 5, 2010

I was going through this Lex/YACC tutorial: [URL]... and I was working along with it. The Lex examples worked fine, but the YACC one quit white compiling

[Code]...

View 5 Replies View Related

Fedora :: RAID 1 - How To Create New Array Without Losing Data

Jan 1, 2010

I have a software RAID array using mdraid that consists of two 1.5TB drives that I use for storage, the array is mounted at /Storage. I am running out of space in the array so I ordered two more 1.5TB drives to create a 4 drive RAID 1+0 array which will be 3TB big. My question is how do I create the new array and not lose any data?

The drives and partitions are sdc1, sdd1, and soon to be sde1, sdf1. I currently have 4 RAID arrays (md0,md1,md2,md3). I think I can create the RAID 1+0 array with the two new drives, copy the data from my current array to the new one, remove the old array, then add the two original drives to the new array. But I wanted to ask on here first to make sure my data doesn't go poof.

View 1 Replies View Related

Server :: Recreate Raid-5 Array Without Loosing Data

Dec 11, 2010

I rebuilt a server and am now trying to recover my large data arrays. The server was ubuntu 10.04lts before. I decided to rebuild it with CentOS simply because I am more familiar with it. I had 2 raid-5 arrays on the old server:4 x 1tb -> md0 5 x 2tb -> md1 The newly built server does not know about these arrays yet. How can I reassemble the arrays without loosing my data? I know the data can still be accessed because booting the server with a live-cd mounts and shows the arrays just fine. Should I boot with a live cd and copy the mdadm config file?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved