Jump to content

quick error question


spanner206

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.