473,770 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Undefined Offset

37 New Member
I am getting this error "Undefined offset: 9 in C:\Course Technology\1687-5\Chapter.10\Up dateContactInfo .php on line 36"
this is the code I am recieving the error on:
[PHP]if (mysqli_num_row s($QueryResult) > 0) {
$Row = mysqli_fetch_ro w($QueryResult) ;
$First = stripslashes($R ow[3]);
$Last = stripslashes($R ow[4]);
$Phone = stripslashes($R ow[5]);
$Address = stripslashes($R ow[6]);
$City = stripslashes($R ow[7]);
$State = stripslashes($R ow[8]);
$Zip = stripslashes($R ow[9]);
mysqli_free_res ult($QueryResul t);
[/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 3295
ronverdonk
4,258 Recognized Expert Specialist
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 Recognized Expert Moderator MVP
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 Recognized Expert Specialist
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
108841
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 work fine, but with error reporting at all they are marked as errors. Why? What am I doing wrong? www.monkeyclaus.org
2
25825
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 line 5 1) reset($kolom1); 2) while(list($cat,$lnk) = each($kolom1)){ 3) kop($cat);
1
4584
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: Undefined offset: 24 in c:\inetpub\wwwroot\classes\file.php on line 348"
4
10192
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, $value) = explode(":", $line, 2);
3
1671
by: pareshgoel | last post by:
class B { virtual ~B(); } class D:public B { virtual ~D(); }
22
7978
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 am using getElelementsByName since these are radio buttons, but it seems that the dynamic element is not seen!!! This is my code... please let me know if there is anything that I am doing wrong! - thanks ---- ....
6
4480
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 advance. Error: Undefined offset: 0 in /es/ePrintsStats/includes/inc.html.cumulative_usage.es.php on line 16 The code: <?php $current_year = date("Y"); $last_year = date("Y")-1;
9
32504
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 try to not use a code and leave it empty the following php errors happens. I dont understand why. Help me. Error shown are: - PHP Notice: in file /index.php on line 132: Undefined offset: 4 PHP Notice: in file /index.php on line 141:...
2
2689
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 function get_imgdim()
0
10260
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...
1
10038
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
9910
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
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();...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
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.