473,801 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql_fetch_arr ay result type error

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

mysql_fetch_arr ay($result, $rtype) where, obviously, $rtype is one of the
three valid values for the result type. This throws an error:
"mysql_fetch_ar ray() [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 4640
Karl Groves wrote:
I'm trying to run mysql_fetch_arr ay with a variable in place of the
optional result type constant, like so

mysql_fetch_arr ay($result, $rtype) where, obviously, $rtype is one of the
three valid values for the result type. This throws an error:
"mysql_fetch_ar ray() [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.c omwrote in
news:13******** *****@corp.supe rnews.com:
Karl Groves wrote:
>I'm trying to run mysql_fetch_arr ay with a variable in place of the
optional result type constant, like so

mysql_fetch_ar ray($result, $rtype) where, obviously, $rtype is one of
the three valid values for the result type. This throws an error:
"mysql_fetch_a rray() [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
7999
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, Quantity FROM restorder_item WHERE Order_Number =58 The code I use to do it is.... $query = "select Menu_Item, Quantity from restorder_item"; $query .= " where Order_Number = ".$_REQUEST;
4
7022
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 * FROM mytable";
2
1801
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 when i limit the mysql query with "WHERE 1 AND last_name LIKE Harder" it gives me these errors Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...
9
7433
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: " . mysql_error()); mysql_select_db("my_dbf") or die("Grr");
7
3324
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 ($result != ''), something more efficient if possible. regards Marc
3
3102
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 never executes the loop. $IsResult is reeves no value. What am I doing wrong Thanks
1
2713
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 line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
5
6649
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 */ function myClass(){
1
2162
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 to do with assignment or garbage collection $con = MYSQLconn(); $res = DSQL::PSQL('SELECT * FROM cat_nav',$con); $res2 = DSQL::PSQL('SELECT * FROM cat_nav',$con); $superres = new SQLResult($res2, $con); while ($ar = Get($res)) { ...
0
9697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9555
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10515
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10291
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10260
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6827
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3771
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.