|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Okay, my second Newbie question and I do hope one day my questions will become more intelligent... I am still fighting with the PHP book and the author now gives:
<?php // Debug info Display function debugDisplay(){ ?> <PRE> $_POST <?php print_r($_POST); ?> $_GET <?php print_r($_GET); ?> </PRE> <?php } // Switch on search/add wizard step switch( $_GET['step']){ // ################# // Search/Add form // ################# case "1": $type = explode(":",$_POST['type']); if ($_POST['Submit']=="Add"){ require($_POST['Submit'].$type[0].'.php'); } else { if ( $_POST['type'] == "Movie:Movie" && $_POST['MovieType'] == ""){ header("Location:form4.php"); } ?> <h1>Search Results</h1> <p>You are looking for a "<?php echo $type[1]?>" named "<?php echo $_POST['Name']?>"</p> <?php } if ($_POST['Debug'] == "on"){ debugDisplay(); } break; // ################# // Add Summary // ################# case "2": $type = explode(":",$_POST['type']); ?> <h1>New <?php echo $type[1]?> : <?php echo $_POST['Name']?></h1> <?php switch( $type[0] ){ case "Movie": ?> <p>Released in <?php echo $_POST['MovieYear']?></p> <p><?php echo nl2br(stripslashes($_POST['Desc']))?></p> <?php break; default: ?> <h2>Quick Bio</h2> <p><?php echo nl2br(stripslashes($_POST['Bio']))?></p> <?php break; } break; // ############### // Starting form // ############### default: require('startform.php'); break; } ?> When I put that in my PHP Expert editor (hm, expert, maybe there is the problem? lol) and display it in IE, then it throws be an error message above the table, showing "Notice: Undefined index: step in c:\program files\easyphp1-7\www\form4.php on line 19" When I display it directly in PHP Expert editor, it shows up fine. Why would IE do that? Also, the author writes "each step in the building of data is guided by the $_GET['step'] index value. It holds the information passed on by the ?step=1 part of the URL. If the page is called without the URL parameter being set, logically enough, it evaluates the 'switch' condition and finds that it doesn't match any of the specific cases. Now, I understand the switch condition is : Then how come that default: require('startform.php'); break; would not work in IE? Any ideas??? Thanks. Learning a bit every day. |
|
#2
|
||||
|
||||
|
In the future, put [php] tags around your PHP code... this way the forum will make your code colourized and it will be prettier for us to read.
Note: You can still edit your post now... but I'd recommend re-pasting your code so the forum doesn't delete your indentation. Which line is line 19? Your book sure doesn't make things easy... this code looks much more complicated then I believe it should be... what is the code suppposed to be teaching you? [which chapter of the book is it under?]... and, if you don't mind me asking, which book is it? (and author) |
|
#3
|
|||
|
|||
|
PHP Code:
Line 19 is switch( $_GET['step']){ "Beginning PHP, Apache, MySQHL Web Development" by Michael K. Glass, Yann Le Scourarnec, Elizabeth Naramore This is at the end of Chapter 5 "Forms" and the section is "Using them All". This is what he said at the beginning of this section: Now that you know most of the form elements, let's create a skeleton for the application. The system will add new items or search for existing ones. As we have no database interfacing so far, this form will just display the information typed in. So, this is the "Skeleton Script" for some app. Througout the book, he has us create a website accessing MySQL for movies, reviews, etc. Thanks for any help! |
|
#4
|
|||
|
|||
|
This is probably due to how error reporting is setup on your system.
Basically the script on line 19 the script is referring to $_GET['step'] , but i'm willing to guess step doesnt exist, the author is hoping that it will fall through to the default action but instead it is displaying the notice (btw this php giving the error, not IE). I wouldn't expect a notice to cause the script to fail, it should display then continue. Try one of the following steps: PHP Code:
becomes PHP Code:
or try calling the script with form4.php?step=0.
__________________
http://www.phptutorials.cjb.net. go on, give it a click! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Switches |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|