jim.davidson Posted April 18, 2007 Share Posted April 18, 2007 I'm using php 5.0 mySql 4.1.21 and dreamweaver 8 I'm getting the following errors Undefined index: contact_areacode Undefined index: contact_phone_prefix Undefined index: contact_first_name Undefined index: contact_last_name Here's the section of code $contact_phone = $_POST['contact_areacode']; $contact_phone = $contact_phone.'-'; $contact_phone = $contact_phone.$_POST['contact_phone_prefix']; $contact_phone = $contact_phone.'-'; $contact_phone = $contact_phone.$_POST['contact_phone_last4']; $contact_name = $_POST['contact_first_name']; $contact_name = $contact_name.' '; $contact_name = $contact_name.$_POST['contact_last_name']; Any idea what's wrong with it or what the error means? Link to comment https://forums.phpfreaks.com/topic/47611-solved-undefined-index/ Share on other sites More sharing options...
per1os Posted April 18, 2007 Share Posted April 18, 2007 The error means that the array indexes 'contact_Areacode' have not beenset/have no value. It is generally good practice to do an isset statement IE: $contact_phone = isset($_POST['contact_areacode'])?$_POST['contact_areacode']:''; Basically if the index contact_areacode in array post isset/has a value than set the variable to that array index if not set the variable to nothing. This will prevent that error. Link to comment https://forums.phpfreaks.com/topic/47611-solved-undefined-index/#findComment-232454 Share on other sites More sharing options...
jim.davidson Posted April 18, 2007 Author Share Posted April 18, 2007 Thank you, I'll give it a whirl Link to comment https://forums.phpfreaks.com/topic/47611-solved-undefined-index/#findComment-232459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.