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

Notice: Undefined index: Error

I am looking for some help if anyone can lend a hand.

I have a simple php website that displays a table from my mysql
database.

To prep for my MCSE I moved my home server to Windows 2003 Standard, I
installed mysql and php 5 to run some of my databases and websites.

Under Linux the site worked fine, under windows I keep getting Notice
Undefined Index error on line 67

I have went back to the basics just pull the data then display and
still get the same error.

60 $sql = "SELECT * from newschool ORDER BY State, CollNam";
61
62 $result = mysql_query($sql, $dbcnx) or die(mysql_error());
63 $number_of_rows = mysql_num_rows($result);
64
65 while ($newArray = mysql_fetch_array($result)) {
66
67 $id = $newArray['id'];
68 $testField = $newArray['testField'];
69
70 echo "The ID is $id and the text is $testField <br>";
Anyone have any thoughts?

Apr 25 '07 #1
6 20836
js********@gmail.com wrote:
I am looking for some help if anyone can lend a hand.

I have a simple php website that displays a table from my mysql
database.

To prep for my MCSE I moved my home server to Windows 2003 Standard, I
installed mysql and php 5 to run some of my databases and websites.

Under Linux the site worked fine, under windows I keep getting Notice
Undefined Index error on line 67

I have went back to the basics just pull the data then display and
still get the same error.

60 $sql = "SELECT * from newschool ORDER BY State, CollNam";
61
62 $result = mysql_query($sql, $dbcnx) or die(mysql_error());
63 $number_of_rows = mysql_num_rows($result);
64
65 while ($newArray = mysql_fetch_array($result)) {
66
67 $id = $newArray['id'];
^^
id, without a $, is a constant. Yet you probably haven't defined that in
your code prior to using it. (I suspect this is a typo though, yes?)
If you have error reporting set to E_ALL, besides warnings and errors,
you'll get notices as well.

HTH

Sh.

Apr 25 '07 #2
Schraalhans Keukenmeester wrote:
js********@gmail.com wrote:
>I am looking for some help if anyone can lend a hand.

I have a simple php website that displays a table from my mysql
database.

To prep for my MCSE I moved my home server to Windows 2003 Standard, I
installed mysql and php 5 to run some of my databases and websites.

Under Linux the site worked fine, under windows I keep getting Notice
Undefined Index error on line 67

I have went back to the basics just pull the data then display and
still get the same error.

60 $sql = "SELECT * from newschool ORDER BY State, CollNam";
61
62 $result = mysql_query($sql, $dbcnx) or die(mysql_error());
63 $number_of_rows = mysql_num_rows($result);
64
65 while ($newArray = mysql_fetch_array($result)) {
66
67 $id = $newArray['id'];
^^
id, without a $, is a constant. Yet you probably haven't defined that in
your code prior to using it. (I suspect this is a typo though, yes?)
If you have error reporting set to E_ALL, besides warnings and errors,
you'll get notices as well.

HTH

Sh.
Skip that, I'm not awake yet.
Is 'id' a valid field in your db?
Try var_dump($newArray) to see what is returned from the db.
Apr 25 '07 #3
<js********@gmail.comwrote in message
news:11**********************@r35g2000prh.googlegr oups.com...
63 $number_of_rows = mysql_num_rows($result);
64
65 while ($newArray = mysql_fetch_array($result)) {
You are certain that "id" is the field name?
If so you could try,
mysql_fetch_array($result, MYSQL_ASSOC)) .
66
67 $id = $newArray['id'];
68 $testField = $newArray['testField'];
69
70 echo "The ID is $id and the text is $testField <br>";
Anyone have any thoughts?
Vince
Apr 25 '07 #4
65 while ($newArray = mysql_fetch_array($result)) {
67 $id = $newArray['id'];
68 $testField = $newArray['testField'];
You should use fetch_assoc() if the index is a string ('id') rather than
a number(0,1,2,3...).

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 25 '07 #5
js********@gmail.com wrote:
I am looking for some help if anyone can lend a hand.

I have a simple php website that displays a table from my mysql
database.

To prep for my MCSE I moved my home server to Windows 2003 Standard, I
installed mysql and php 5 to run some of my databases and websites.

Under Linux the site worked fine, under windows I keep getting Notice
Undefined Index error on line 67

I have went back to the basics just pull the data then display and
still get the same error.

60 $sql = "SELECT * from newschool ORDER BY State, CollNam";
61
62 $result = mysql_query($sql, $dbcnx) or die(mysql_error());
63 $number_of_rows = mysql_num_rows($result);
64
65 while ($newArray = mysql_fetch_array($result)) {
66
67 $id = $newArray['id'];
68 $testField = $newArray['testField'];
69
70 echo "The ID is $id and the text is $testField <br>";
Anyone have any thoughts?
Don't worry about those who are telling you to use mysql_fetch_assoc().
Your code is just fine; the default for mysql_fetch_array() is to
fetch both numeric and associative indicies. It may just be a little
slower than mysql_fetch_assoc(), but you'll never notice the difference.

As for your problem - it looks like you don't have a column named 'id'
in the `newschool` table. Perhaps when you created the database here
you named it something else (or had a finger check)?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 25 '07 #6
Don't worry about those who are telling you to use mysql_fetch_assoc().
Your code is just fine; the default for mysql_fetch_array() is to fetch
both numeric and associative indicies. It may just be a little slower
Thank you.

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 26 '07 #7

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

Similar topics

2
by: siliconmike | last post by:
apache error log: /var/log/httpd-error.log gets filled up with various notices such as: php notice: Use of undefined constant name - assumed 'name' in xxxxx on line 1, referer: yyyy the...
3
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice:...
2
by: Reggie | last post by:
am trying to create a a upload file.am uploading files ok but i recieve this message. Notice: Undefined variable: uploaded_size in /home/fhlinux169/c/ clashoff.co.uk/user/htdocs/upload.php on...
3
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if...
5
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : ...
1
by: francsutherland | last post by:
Notice: Undefined index: send in D:\Domains\workingdata.co.uk\wwwroot\contact_text.php on line 7 Hi, I've started getting this error in the contact page form of my website. The web hosting...
10
by: FutureShock | last post by:
I have since recently turned up my error reporting on a production site to E_ALL to ensure I am using 'best practices' when writing out code. So far it has helped me discipline myself with...
11
by: stealthmode666 | last post by:
New to .php so need script help. I want to know how to stop this being displayed when I click submit. Notice: Undefined index: homeowner in E:\domains\r\...\user\htdocs\...\form.php on line 166 ...
2
by: Smellydog | last post by:
I'm having a strange issue with PHP version 5.2.8 running on Windows Vista with Lighttpd. I receive a Notice that says the following: Notice</b>: Undefined index: name in...
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...
1
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
agi2029
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,...
0
isladogs
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.