Jump to content

Recommended Posts

I have been using an application that was working fine using php 5.6.39 but I have to update my version of php to 7.x and am trying to fix the issues relating to that conversion.  I am currently running into this error message:  Notice: Undefined index: sqNum_00 in C:\usbwebserver865\root\superbowlLV\signup.php on line 23

The block of code that this refers to is as follows:

if ( isset($_REQUEST['sqSelect_Submit']) ) {
	$SQ=0;
	$SQcount = 100;
	for ($i=0;$i<$SQcount;$i++) {
		if ($i<10) { $SQarray[$i] = $_POST["sqNum_0$i"]; }  //This is line 23 referenced in the error message
		
		else { $SQarray[$i] = $_POST["sqNum_$i"]; }
		if ( isset($SQarray[$i]) ) { 
			$SQ++;
			echo $SQarray[$i]." "; 
			echo ('<input type="hidden" name="square_'.$SQ.'" value="'.$SQarray[$i].'">');
			echo ('<input type="hidden" name="sqTotal" value="'.$SQ.'">');
			if ( $SQ == 10 ) { echo "<p>Maximum of 10 Squares per selection</p>"; break; } // limit to 10
		}
	}

Any assistance provided would be greatly appreciated.  BTW, this error message is repeated for the 100 squares in the grid such as sqNum_01 etc. although it always refers to the same line number.

Link to comment
https://forums.phpfreaks.com/topic/312660-notice-undefined-index-issue/
Share on other sites

the code is blindly looping over 100 possible values, without testing if they exist before referencing them. this error was always occurring, but was probably not being reported or displayed.

you should use an array for the form field, with the array index being the 0-99 value. this will eliminate the need for the logic to take the $_POST[sqNum_xx] value and put it into $SQarray[xx]. you will already have an array of data from the form that the if ( isset($SQarray[$i]) ) { can test and use.

 

Thank you both (Barand and mac_gyver) for your responses.  This is not coding I have developed...the developer has gone off the grid so I am trying to "fix" the myriad of problems with the code by googling the error messages as they come up. 

Barand...I assume that the code you asked me to enter was to determine what the POST array contained and if that is the case, this is what was echoed after I selected square # 64

Array ( [sqNum_64] => 64 [sqSelect_Submit] => Submit ) 

mac_byver...I wouldn't know how to use an array...sorry.

 

is this code doing anything else with the submitted values beyond building the hidden fields in the form?

btw - the sqTotal field being repeatedly output is pointless.  it should just be output once, after the end of the looping, and i would even venture to guess that it is not needed anyways.

1 hour ago, metroman90210 said:

...the developer has gone off the grid

Probably one of his other clients caught up with him

 

1 hour ago, metroman90210 said:

Array ( [sqNum_64] => 64 [sqSelect_Submit] => Submit ) 

In which case, sqNum_64 is the only one out of the hundred that won't give you an error.

Do as mac_gyver suggested and name your inputs ...

name="sqNum[n]"

where n is a number from 1 to 100.

You can then process the input withsomething like ...

foreach ($_POST['sqNum'] as $i => $val) {
    // process $i
}

Out of curiosity, what does the input form code look like and what is it supposed to do?

Rather than trying to explain how this is supposed to work, I have set up the application on a webhost running php version 7.4.16

If you click on a square (you can click on a maximum of 10, you will see that it takes you to a page that is supposed to list the square numbers you have selected.  After "fixing" some of the code, this is what that page looks like and as you can see, the square numbers are not being displayed.

 

SuperBowl Squares Application

It is slightly different from yours

  1. A set of selections is valid only for a selected game, whereas yours is valid for 19 games.
  2. I update the database with each selection as soon as it is clicked (recording game_id/user_id/square_id)
  3. There is no on-line monetary collection. You paid the club treasurer in cash.

image.thumb.png.0d90a159b63d575c2add2945f9ee3c73.png

One problem was that no-one wanted to bet on my team's score ending (or starting) with anything other than zero, even though I remember we did score once.

This looks exactly like mine. Mine is only good for one game...there are payouts for every score in the game and that scoring is done manually by me. All the squares must be sold before the numbers in the left hand and bottom panels are randomly generated so no player knows what numbers he will have until the grid is sold out.  I collect all money before the game starts either by check, benmo or paypal.

 

If your application is available, I would love to take a look at it assuming it is open source.  If it is not open source, let me know the cost of it.  I assume it would work with php versions 7.4.x?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.