473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Fetching More than one Array

The1corrupted
134 100+
This is truly frustrating. I'm trying to fetch one array from two different tables. Personally, I think it would work but I always get this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Vardaes\more1.php on line 50

Well... here's line 50 and the array fetch just before it.

$tablesummon=mysql_query("SELECT * FROM user_table WHERE cn='$user'");
$array=mysql_fetch_array($tablesummon);

$summon=mysql_query("SELECT * FROM rooms WHERE ns='$array[12]' , ew='$array[13]' , ud='$array[14]'");
$ray=mysql_fetch_array($summon);

I'm working with an XYZ coordinate system, or trying to at least. I'm trying to pull back the correct coordinates for the correct display.

I've even tried parsing it with a while statement and it still comes up with that same error. Need help badly.
Feb 20 '07 #1
9 1578
ronverdonk
4,258 Expert 4TB
You must specify an AND relation in your second query, like this:
Expand|Select|Wrap|Line Numbers
  1. $summon=mysql_query("SELECT * FROM rooms 
  2.            WHERE ns='$array[12]' 
  3.            AND ew='$array[13]' 
  4.            AND ud='$array[14]'");
It is also good practise to catch any errors that might result from the SELECT statement, then your statement must be coded something like:
Expand|Select|Wrap|Line Numbers
  1. $summon=mysql_query("SELECT * FROM rooms 
  2.            WHERE ns='$array[12]' 
  3.            AND ew='$array[13]' 
  4.            AND ud='$array[14]'")
  5.   or die ("SELECT error": ".mysql_error());
Ronald :cool:
Feb 20 '07 #2
The1corrupted
134 100+
This only brings up more problems to my attention. Sessions... somehow I can never get these right. I've been through the tutorials and I'm stuck scratching my head because when I put it into practice, it blows up on me.

This also has to do with MySQL because I want to compare the session variables to pull back the right info.
Feb 20 '07 #3
ronverdonk
4,258 Expert 4TB
Now let's get this straight: don't change the thread subject!

Did my reply help you with your SELECT query or not? And if not, what was the error this time?

Ronald :cool:
Feb 20 '07 #4
The1corrupted
134 100+
Quite... Guess I'll just start a new thread, then.
Feb 20 '07 #5
ronverdonk
4,258 Expert 4TB
That still gives no answer to the question whether the post (AND relations) helped or not.

Ronald :cool:
Feb 20 '07 #6
The1corrupted
134 100+
Okay... More to do with arrays. How can I get a rolling output from a mysql table?

[PHP]
<?php
session_start();
$x=$_SESSION['xcoord'];
$y=$_SESSION['ycoord'];
$z=$_SESSION['zcoord'];

$checklocal=mysql_qyery("SELECT *
FROM user_table
WHERE ns='$x'
AND ew='$y'
AND ud='$z'");
$checkarray=mysql_fetch_array($checklocal);
?>[/PHP]
Obviously, this will equal more than one entry so how do I keep it rolling until none are left?
Feb 20 '07 #7
ronverdonk
4,258 Expert 4TB
Use the mysql_fetch_* command. Like the following example that gets one row at a time from the result set and echoes the content of column 'column_name' to the screen.

[php]while ($checkarray=mysql_fetch_array($checklocal)) {
echo $checkarray['column_name' ];
// ... etc ...
}[/php]

Ronald :cool:
Feb 21 '07 #8
The1corrupted
134 100+
Coolies! Thanks.
Feb 22 '07 #9
ronverdonk
4,258 Expert 4TB
You are welcome (of course)!

Ronald :cool:
Feb 22 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Arsen V. | last post by:
Hello, Does anyone know if an object or how to create one, that will allow me to fetch up to 10 URLs (containing XML-feed data) in an extremelly fast server side fashion? If the request is...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
7
by: multicherry | last post by:
Hi, Having searched for a way to fetch a window object by name, all I came across were answers along the line of... "All you have to do is say windowObj = window.open("blah", "name");" which...
7
by: Mark | last post by:
let's say i have a table in my database, with only one column. all i want to do is retrieve a list of the entries.. i could do it like this $result = mysql_query("SELECT * FROM t1"); while( $x =...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
1
by: asenthil | last post by:
Hai, i had tried to write a string which is fetched from a database into a file.... Here are my codings to write that fetched string into a text file... HANDLE hFile; DWORD wmWritten;...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
1
by: Bhavesh | last post by:
Hi Bruce, Thanks For Reply. U were right, Needed to pass string , but also need to pass size of Data( instead of 16, passed actual length of data). So that worked for me & didn't get any...
4
by: tokcy | last post by:
HI every one, i am using tooltip on click of link and i want like when that tooltip open then background window would be blure(). can anyone help me...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.