473,396 Members | 1,917 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.

session registering a row from a mysql search

Bob
Hi,
I am having trouble registering a row from a mysql query

so far I have the mysql part working :

while ( $val = mysql_fetch_array( $result ))
{
print("<tr><td>$val[0]</td>
<td>$val[1]</td>
<td>$val[2]</td>
<td>$val[3]</td>
<td>$val[4]</td>
</tr>\n");
}

But, getting these fields into an array for which to register these is a bit
of a problem
any help would be appreciated, as soon as I do the fetch and priint them out
these fields seem lost to the world.

Thanks
Bob
Thanks
Jul 17 '05 #1
4 1849
I noticed that Message-ID: <zm********************@nasal.pacific.net.au>
from Bob contained the following:

while ( $val = mysql_fetch_array( $result ))
{
print("<tr><td>$val[0]</td>
<td>$val[1]</td>
<td>$val[2]</td>
<td>$val[3]</td>
<td>$val[4]</td>
</tr>\n");
}


try $val['fieldname']

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Bob wrote:
I am having trouble registering a row from a mysql query
What do you mean with "registering"?
so far I have the mysql part working :

while ( $val = mysql_fetch_array( $result ))
{
print("<tr><td>$val[0]</td>
<td>$val[1]</td>
<td>$val[2]</td>
<td>$val[3]</td>
<td>$val[4]</td>
</tr>\n");
}
OK, this will print as many rows as the number of records returned from
the database.
But, getting these fields into an array for which to register these is a bit
of a problem
any help would be appreciated, as soon as I do the fetch and priint them out
these fields seem lost to the world.


Are you, by any chance, trying to access $val /outside/ the while loop?

<?php
while ($val = mysql_fetch_array($result)) {
print("...");
$valid_data_array = array($val[0], $val[1], $val[2]); // ok here
}
$invalid_data_array = array($val[0], $val[1], $val[2]); // wrong!
?>

You might want to increase the level of error_reporting in your scripts
to have php itself tell you about the use of uninitialized variables and
a few other mistakes in coding that it can catch.
Put these lines at the very beginning of your scripts

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', '1');
?>

HTH
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3
Bob

"Pedro Graca" <he****@hotpop.com> wrote in message
news:2g************@uni-berlin.de...
Bob wrote:
I am having trouble registering a row from a mysql query


What do you mean with "registering"?
so far I have the mysql part working :

while ( $val = mysql_fetch_array( $result ))
{
print("<tr><td>$val[0]</td>
<td>$val[1]</td>
<td>$val[2]</td>
<td>$val[3]</td>
<td>$val[4]</td>
</tr>\n");
}


OK, this will print as many rows as the number of records returned from
the database.
But, getting these fields into an array for which to register these is a bit of a problem
any help would be appreciated, as soon as I do the fetch and priint them out these fields seem lost to the world.


Are you, by any chance, trying to access $val /outside/ the while loop?

<?php
while ($val = mysql_fetch_array($result)) {
print("...");
$valid_data_array = array($val[0], $val[1], $val[2]); // ok here
}
$invalid_data_array = array($val[0], $val[1], $val[2]); // wrong!
?>

You might want to increase the level of error_reporting in your scripts
to have php itself tell you about the use of uninitialized variables and
a few other mistakes in coding that it can catch.
Put these lines at the very beginning of your scripts

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', '1');
?>


thanks for your reply

i got around it quite simply :
(hides head in shame)

print("<tr><td>$val[0]</td>
<td>$val[1]</td>
<td>$val[2]</td>
<td>$val[3]</td>
<td>$val[4]</td>
</tr>\n");
$prod_id = $val[0];
$prod_name = $val[1];
$price = $val[2];
$quantity = $val[3];
$stock = $val[4];

then registered the variables i assigned val[n] too.
total newbie me.
Jul 17 '05 #4
Bob

"Pedro Graca" <he****@hotpop.com> wrote in message
news:2g************@uni-berlin.de...
Bob wrote:
I am having trouble registering a row from a mysql query


What do you mean with "registering"?
so far I have the mysql part working :

while ( $val = mysql_fetch_array( $result ))
{
print("<tr><td>$val[0]</td>
<td>$val[1]</td>
<td>$val[2]</td>
<td>$val[3]</td>
<td>$val[4]</td>
</tr>\n");
}


OK, this will print as many rows as the number of records returned from
the database.
But, getting these fields into an array for which to register these is a bit of a problem
any help would be appreciated, as soon as I do the fetch and priint them out these fields seem lost to the world.


Are you, by any chance, trying to access $val /outside/ the while loop?

<?php
while ($val = mysql_fetch_array($result)) {
print("...");
$valid_data_array = array($val[0], $val[1], $val[2]); // ok here
}
$invalid_data_array = array($val[0], $val[1], $val[2]); // wrong!
?>


doh !
basic tenets of structured programming.
Jul 17 '05 #5

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

Similar topics

1
by: Bob | last post by:
Hi y'all I have a php script which access mysql after being invoked from a html page Will registering the session in the html page allow me to then use the called php script to then access a third...
1
by: windandwaves | last post by:
Hi Folks I have been trying to find out how I can save a session - so far without success. I use PHP in combination with MySql and I would like my users to be able to save their sessions in my...
1
by: windandwaves | last post by:
Hi Folk, Below is a message that I posted on alt.html I now have some more feedback from people who experienced an error with safari and they tell me that the PHPsessID changes while running a...
4
by: Chris Stegeman | last post by:
Hello there, On my site people have to log in and automatically start a session. An authorized login grants access to other pages and MySQL data. However when the user waits to long, the server...
14
by: windandwaves | last post by:
Hi Folk Forgive me for asking such a basic question... I have a site where I want to track the user from start till end... To do this, I have setup the following structure for each page,...
1
by: Larry Neylon | last post by:
Hi, I'm working on a VBScript application on IIS6 and I'm looking for some advice about the best way of replacing or improving session variable usage. The application is in a secure extranet...
6
by: Vyoma | last post by:
This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I have been lurking around at several forums with regard to login and user authentication scripts and...
4
by: | last post by:
Hello... i have a table which contains a column named "ask" and a column named "per"... my think is that i want to search in "ask" and echo the data stored in "per" for this entry... How do i do...
1
tolkienarda
by: tolkienarda | last post by:
hi all i seem to be having a problem with session variables, and registering sessions. i am runing wamp5 and i think that i need to change something in the php.ini file cause i basicaly coppied...
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:
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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.