473,395 Members | 1,948 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.

Undefined Offset

I am getting this error "Undefined offset: 9 in C:\Course Technology\1687-5\Chapter.10\UpdateContactInfo.php on line 36"
this is the code I am recieving the error on:
[PHP]if (mysqli_num_rows($QueryResult) > 0) {
$Row = mysqli_fetch_row($QueryResult);
$First = stripslashes($Row[3]);
$Last = stripslashes($Row[4]);
$Phone = stripslashes($Row[5]);
$Address = stripslashes($Row[6]);
$City = stripslashes($Row[7]);
$State = stripslashes($Row[8]);
$Zip = stripslashes($Row[9]);
mysqli_free_result($QueryResult);
[/PHP]
My array has 9 elements, everytime I change the indexes listed above to 1 less, assuming zero-based array, the data that is in $First name is displayed in the $Last name field. Please help!!
Thanks
Jan 6 '07 #1
3 3278
ronverdonk
4,258 Expert 4TB
When your $row has 9 elements, the first one is $Row[0] and the last one is $Row[8], so $Row[9] is outside the range.

Ronald :cool:
Jan 6 '07 #2
acoder
16,027 Expert Mod 8TB
My array has 9 elements, everytime I change the indexes listed above to 1 less, assuming zero-based array, the data that is in $First name is displayed in the $Last name field. Please help!!
Thanks
Check your database and SQL if that is the case. Your array is zero-based. row[3] will be the fourth field.
Jan 6 '07 #3
ronverdonk
4,258 Expert 4TB
I suppose you did a SELECT * in your query. Who gave you the quarantee that the sequence of the columns in your table would be identical to the order you created them in? If you want them in a specific order, issue a SELECT col1, col2, .... etc. Same applies to row sequence.

It usually is so, but MySQL gives no guarantee at all, they even deny it, that it is. Remember, the whole point of a relational setup is to decouple data storage and presentation.

See also this post about that same subject.

Ronald :cool:
Jan 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: lawrence | last post by:
I just switched error_reporting to ALL so I could debug my site. I got a huge page full of errors. One of the most common was that in my arrays I'm using undefined offsets and indexes. These still...
2
by: Steven | last post by:
Hi All, I am moving some php code from a Linux machine to a Windows 2000 machine with the code belowe I get the following error : Notice: Undefined offset: 1 in c:\inetpub\wwwroot\test.php on...
1
by: google | last post by:
Hello, I'm having major problems trying to get my head round this problem. I'm trying to generate an error free script, however, I still cannot sort out this loop. I get a "Notice:...
4
by: Richard Lawrence | last post by:
Hi there, I'm having a problem with PHP which I'm not sure how to best solve. Here is the code: $fp = fopen("comments.txt", "r"); while(!feof($fp)) { $line = fgets($fp, 1024); list($key,...
3
by: pareshgoel | last post by:
class B { virtual ~B(); } class D:public B { virtual ~D(); }
22
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I...
6
by: nicy12 | last post by:
Hi! my name is Peter. iam working on the php platform. while trying to run and compile a program i get the undefined offset error iam nto much familiar with this error . Please help me . Thanks in...
9
by: simple12 | last post by:
Hello I have a script which have the facility of entering any code to some part of a webpage. I have some problems with it. When i put some code in the script then their is no error shown. When i...
2
by: neridaj | last post by:
Hello, I'm trying to figure out how to get rid of these errors: Notice: Undefined offset: 1 in output_fns.php on line 315 Notice: getimagesize() : Read error! in output_fns.php on line 315...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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.