Strange array issue, never happened before.


Posted on 16th Feb 2014 07:03 pm by admin

mysql_fetch_array returns 1 array per call. Generally that's why it is inserted into a while statement. I generally loop through them in a while statement and put them all in a master array so I have all the results in one place instead of having to use them on the spot in the while loop. So here is what I generally do:
// If the flag all is set then run an "all" query. else we need to do some specifics on the query instead.
Code: [Select]<?php
if ($flag['all'] == 1) {
$sql = 'SELECT * FROM data_resources';
}else {
$sql = '';
}

#### Run Query ####
$data = array(); //This is the master array that will contain all results.
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
$data[] = $row;
}
?>
If I echo out the data array inside the while statement it works properly, but when I try to access it outside of the while it doesn't work. What is going on? Normally this works just fine.

No comments posted yet

Your Answer:

Login to answer
272 Like 45 Dislike
Previous forums Next forums
Other forums

Had a simple form script that suddenly stopped working
It was made about a year ago and had been working fine. Last time it was known to work for sure was

License Issue - service type user
Hi,

I would like to understand the following issue regarding sap license.
I wish to

listcube issue
Hi
I have a virtual cube ZREMOTE. I use Tcode "listcube" to retrieve contents. I use of the

How to search for several parameters from objects in a database?
I have a database with lots of information about objects.
Now I would like to search for 4 or 5 p

problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi

Problem with Subscreen
Dear Experts ,
I am facing a problem with the subscreens. My senario is as follows :

Why is this query failing?
Why is this not working?
$query = "SELECT * FROM `users` WHERE `userid` = " . $USERID

A problem with my GD class
Hello,

I created a nice (and simple for now) GD class.
The problem is , it works great on

Error when call dll from oracle
Hi all, please help me!

I have dll write C language, I want call it from oracle procedur

isset undefined variable
Hi all,

Hope someone can point out the obvious. I've a log in script, if you dont enter a use

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash