473,395 Members | 1,343 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,395 software developers and data experts.

mysql_fetch_array result type error

I'm trying to run mysql_fetch_array with a variable in place of the
optional result type constant, like so

mysql_fetch_array($result, $rtype) where, obviously, $rtype is one of the
three valid values for the result type. This throws an error:
"mysql_fetch_array() [function.mysql-fetch-array]: The result type should
be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH."

I'm not quite sure what the issue here is, other than that I'm replacing a
constant with a variable. I'm looking for a solution that will allow me to
(variably) be able to dictate this value.

TIA

--
Karl Groves

Mar 22 '07 #1
2 4618
Karl Groves wrote:
I'm trying to run mysql_fetch_array with a variable in place of the
optional result type constant, like so

mysql_fetch_array($result, $rtype) where, obviously, $rtype is one of the
three valid values for the result type. This throws an error:
"mysql_fetch_array() [function.mysql-fetch-array]: The result type should
be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH."

I'm not quite sure what the issue here is, other than that I'm replacing a
constant with a variable. I'm looking for a solution that will allow me to
(variably) be able to dictate this value.

TIA
I assume your variable $rtype contains string of the constants.
"MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH" are CONSTANTS.
As such, $rtype need to contains the value of the constants.
ie. assign $rtype = MYSQL_NUM *NOT* $rtype = 'MYSQL_NUM'
(Note the quote)

Hendri
Mar 23 '07 #2
Hendri Kurniawan <as****@email.comwrote in
news:13*************@corp.supernews.com:
Karl Groves wrote:
>I'm trying to run mysql_fetch_array with a variable in place of the
optional result type constant, like so

mysql_fetch_array($result, $rtype) where, obviously, $rtype is one of
the three valid values for the result type. This throws an error:
"mysql_fetch_array() [function.mysql-fetch-array]: The result type
should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH."

I'm not quite sure what the issue here is, other than that I'm
replacing a constant with a variable. I'm looking for a solution
that will allow me to (variably) be able to dictate this value.

TIA

I assume your variable $rtype contains string of the constants.
"MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH" are CONSTANTS.
As such, $rtype need to contains the value of the constants.
ie. assign $rtype = MYSQL_NUM *NOT* $rtype = 'MYSQL_NUM'
(Note the quote)
UGH. So simple. Thanks

--
Karl Groves

Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Noel Wood | last post by:
Hello I keep getting a warning ... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in "name of my php file" when I run this query.... SELECT Menu_Item,...
4
by: Theo | last post by:
hi all this is probably another simple one, but the web doesnt seem to have an answer that I can find. Veeeery simple code. each row has 10 columns. require('db.php'); $query = "SELECT *...
2
by: wrw[three] | last post by:
Hey Okay so i have a page that lists a bunch of clients... then another page that would limit it to a specific chosen client.... the one that lists all the clients is working just fine, however...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
7
by: monomaniac21 | last post by:
Hi all! How can you get rid of the error that displays if you do a query which returns no result and then try and fetch the array, WITHOUT having to put the while in another conditional like if...
3
by: Patrick | last post by:
Hi I am trying to write a simple database class to encapsulate all the database functions in one. Howerver I am having problems with while($row = mysql_fetch_array($IsResult,MYSQL_NUM)) line it...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
5
by: jmDesktop | last post by:
In my code I cannot figure out how to retrieve multple rows from my returned array from a class method. I have tried: <?php class myClass { private $connection; /* Class constructor */...
1
by: byteit101 | last post by:
I was working with OOP, and was testing a sql result class, but it gives me the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I think it has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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.