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";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
for($x=0; $x<$numrows; $x++)
$row_arrays[$x] = mysql_fetch_array($result);
//test row 1
foreach($row_arrays[1] as $count)
print "$count<br>";
result for each print is the column number (0-9) and each id(0,a,1,b,2,c
etc). But if I use mysql_fetch_array($result, 'MSQL_ASSOC') as the docs
say, I get the 'The result type should be either MYSQL_NUM, MYSQL_ASSOC or
MYSQL_BOTH' error. No quotes, additional error about undefined constant. I
figure using this would get the array including the id only and not include
the number. Perhaps its the wrong assumption?
thanks 4 6997
Theo wrote: 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"; $result = mysql_query($query); $numrows = mysql_num_rows($result);
for($x=0; $x<$numrows; $x++) $row_arrays[$x] = mysql_fetch_array($result);
//test row 1 foreach($row_arrays[1] as $count) print "$count<br>";
result for each print is the column number (0-9) and each id(0,a,1,b,2,c etc). But if I use mysql_fetch_array($result, 'MSQL_ASSOC') as the docs say, I get the 'The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH' error. No quotes, additional error about undefined constant. I figure using this would get the array including the id only and not include the number. Perhaps its the wrong assumption?
thanks
Hi,
the second parameter of mysql_fetch_array function must be an INTEGER.
MYSQL_BOTH, MYSQL_NUM and MYSQL_ASSOC are contants and have to be
specified without single or double quote.
bye
Gabriele Farina *DarkBard* <da******@extending-php.net> wrote in
news:D1********************@news3.tin.it: Theo wrote: 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"; $result = mysql_query($query); $numrows = mysql_num_rows($result);
for($x=0; $x<$numrows; $x++) $row_arrays[$x] = mysql_fetch_array($result);
//test row 1 foreach($row_arrays[1] as $count) print "$count<br>";
result for each print is the column number (0-9) and each id(0,a,1,b,2,c etc). But if I use mysql_fetch_array($result, 'MSQL_ASSOC') as the docs say, I get the 'The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH' error. No quotes, additional error about undefined constant. I figure using this would get the array including the id only and not include the number. Perhaps its the wrong assumption?
thanks
Hi,
the second parameter of mysql_fetch_array function must be an INTEGER. MYSQL_BOTH, MYSQL_NUM and MYSQL_ASSOC are contants and have to be specified without single or double quote.
bye
Hi thanks, yes I tried that as well.
but this morning (I always think better in the late mornings) I used
mysql_fetch_assoc instead and all is good.
However, on the fetch_array method, when I used MYSQL_ASSOC alone (first
way I tried it) I get the undefined constant error. Well ok not an error, a
notice - "PHP Notice: Use of undefined constant MSQL_ASSOC - assumed
'MSQL_ASSOC'"It looks like it doesnt know what this constant is, so its
changing it to a string. Question is why its not identifying the constant.
Academic now but I dont like it when simple functions dont work they way
they are supposed to... just bugs me because I might need it later :-)
cheers!
On Sat, 23 Oct 2004 17:23:58 -0000, Theo <in*****@noemail.com> wrote: when I used MYSQL_ASSOC Use of undefined constant MSQL_ASSOC
Spot the difference...
--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Andy Hassall <an**@andyh.co.uk> wrote in
news:k1********************************@4ax.com: On Sat, 23 Oct 2004 17:23:58 -0000, Theo <in*****@noemail.com> wrote:
when I used MYSQL_ASSOC Use of undefined constant MSQL_ASSOC
Spot the difference...
That loud sound you hear is me going
doh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!
I knew it was going to something stupid I did ;o) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: james |
last post by:
I am new to PHP and am trying to run a simple query and display the
result, with no luck. Here is the code I am using.
<?php
//start session
session_start();
//store cmpid from querystring...
|
by: Good Man |
last post by:
Hey there
I have a dumb question....
Let's say i have a database full of 4000 people.... I select everything
from the database by:
$result = mysql_query("SELECT * FROM People");
|
by: Dave Moore |
last post by:
Hi All,
I've got a simple query hopefully somebody can clear up for me. I need to
make a query on a database to select a set of table rows, using something
like:
$result = mysql_query($query);...
|
by: Marcel Brekelmans |
last post by:
Hello,
I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example:
I have a simple table 'tblName':
ID Name
1 Jane
2 Joe
2 Doe
|
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: " ....
| |
by: monomaniac21 |
last post by:
hi all
im querying a db for two rows which are always returned. how can i
reference each row and output its contents without using a while loop.
ive tried:
$row = mysql_fetch_array($result);...
|
by: Karl Groves |
last post by:
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...
|
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...
|
by: William Gill |
last post by:
given the query:
SELECT * FROM customers
left join addresses
on customer.cusid=addresses.cusid
The mysql monitor returns all fields from both tables, including
repeating the field matching...
|
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...
|
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...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |