Hi. I use WampServer Version 2.0 and when I tried to execute this script I got an error: Notice: Undefined index: name in C:\wamp\www\xxx\job_preview.php on line 8 Notice: Undefined index: name in C:\wamp\www\xxx\job_preview.php on line 17 Notice: Undefined variable: normal_price in C:\wamp\www\xxx\job_preview.php on line 23 8 if($_REQUEST["name"]!="") 9 { 10 $Title=$_REQUEST["name"]; 11 } 12 else 13 { 14 $Title=$_REQUEST["Title"]; 15 } 16 17 if($_REQUEST["name"]!="") 18 { 19 $highlight=$extra_price; 20 } 21 else 22 { 23 $highlight=$normal_price; 24 } 25 $wd2=(addslashes($_POST["Available_positions"])); 26 ?> PHP: Can anyone help me to solve this problem?
Hello, Those are errors of type "E_NOTICE", it's a good practice to show them if you are developing but they should be hidden from public. From this point you have 2 choices: 1 - Correct those minor errors 2 - Hide and ignore them ------ 1 - replace if($_REQUEST["name"]!="") PHP: with if(isset($_REQUEST["name"]) && $_REQUEST["name"]!="") PHP: ------ 2 - In your PHP configuration file (php.ini) set "error_reporting like this: error_reporting = E_ALL & ~E_NOTICE Code (markup): ------ Resource: http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
Thank you a lot. I have already solved it on the 2nd way, but I would like to solve it in the code. As you said I solved lines 8 and 17 with replacing, but I still have a problem with line 23. What to do with line 23? Thank you again.
Try to understand PHP's error messages: You're telling PHP to assign a value which he doesn't know (because it has not been set in the previous lines of code) this will suppress the error but may bring newer error (depending on how you wrote your code). if(isset($normal_price)) $highlight=$normal_price; PHP: I guess this is not what you want to do, at line 23 $normal_price should already have been set