spanner206 Posted November 8, 2013 Share Posted November 8, 2013 hi bin getting this undefined variable notice and i was just wondering what it meant, because everything is working the way i want it to but getting this notice at the bottom is getting a bit stupid ( ! ) Notice: Undefined variable: errors in C:\wamp\www\AddLeads\addeadstemplate.php on line 99Call Stack#TimeMemoryFunctionLocation10.0000158288{main}( )..\addeadstemplate.php:0 this is the section its in <?php if (count($errors)==0) { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 ?> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/283724-quick-error-question/ Share on other sites More sharing options...
BrodaNoel Posted November 8, 2013 Share Posted November 8, 2013 It's simple. The "warning" (is not an error) say: "The $errors is not defined" So.. The $errors is not defined... It not have a value. If you use a var without a value, or not defined, you will see a warning. In the top of you site, add this line: $errors = ''; So, $errors will have a value... But, dont worry, is only a warning... not an error. Link to comment https://forums.phpfreaks.com/topic/283724-quick-error-question/#findComment-1457534 Share on other sites More sharing options...
trq Posted November 8, 2013 Share Posted November 8, 2013 But, dont worry, is only a warning... not an error. Don't do that. Code producing warnings should always be fixed. Link to comment https://forums.phpfreaks.com/topic/283724-quick-error-question/#findComment-1457535 Share on other sites More sharing options...
spanner206 Posted November 8, 2013 Author Share Posted November 8, 2013 cheers m8 that worked great Link to comment https://forums.phpfreaks.com/topic/283724-quick-error-question/#findComment-1457536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.