Click here to Skip to main content
15,313,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey Guys I am trying to create page for the create Customer but getting this error please help

What I have tried:

PHP
  1  <?php require_once("dataconfig.php"); ?>
  2  <?php
  3  if (isset($_POST['signup'])){
  4  
  5      $name=$_POST['company_name'];
  6      $cid=$_POST['company_id'];
  7      $adress=$_POST['adress'];
  8      $city=$_POST['City'];
  9      $state=$_POST['state'];
 10      $email=$_POST['email'];
 11      $phone=$_POST['Phone'];
 12      $owner=$_POST['owner'];
 13      $ownerphone=$_POST['ownerphone'];
 14      $contactperson=$_POST['contactperson'];
 15      $contactpersonphone=$_POST['contactpersonphone'];
 16      $contactpersonemail=$_POST['contactpersonemail'];
 17      $contactpersonposition=$_POST['contactpersonposition'];
 18      $coment=$_POST['coment'];
 19      $date=date('Y-m-d');
 20      if(filter_var($email, FILTER_VALIDATE_EMAIL)){
 21        $sql = mysqli_query($conn, "SELECT * FROM users WHERE email = '{$email}'");
 22        if(mysqli_num_rows($sql) > 0){
 23            echo "$email - This email already exist!";
 24        }else{
 25            if(isset($_FILES['image'])){
 26                $img_name = $_FILES['image']['name'];
 27                $img_type = $_FILES['image']['type'];
 28                $tmp_name = $_FILES['image']['tmp_name'];
 29                
 30                $img_explode = explode('.',$img_name);
 31                $img_ext = end($img_explode);
 32  
 33                $extensions = ["jpeg", "png", "jpg"];
 34                if(in_array($img_ext, $extensions) === true){
 35                    $types = ["image/jpeg", "image/jpg", "image/png"];
 36                    if(in_array($img_type, $types) === true){
 37                        $time = time();
 38        $new_img_name = $time.$img_name;
 39      if(move_uploaded_file($tmp_name,"images/".$new_img_name)){
 40      $sql = "INSERT INTO `company`(`name`, `company_id`, `address`, `city`,`state`, `email`, `pnumber`, `Owner`, `Opnumber`) Values
 41      ('$name','$cid','$adress','$city','$email','$phone','$owner','$ownerphone')" ; 
 42       $query= mysqli_query($dbc,$sql);
 43  
 44       if ($query){
 45  
 46          $sql2 = "INSERT INTO `companyid`(`id`, `company_id`, `contact_person`, `name`, `email`, `adress`, `city`, `State`, `pNumber`, `Owner`, `contact_number`, `contact_email`, `Contact_position`, `date`, `Coment`) Values
 47          ('','$cid','$contactperson','$name','$email','$adress','$city','$state','$phone','$owner','$contactpersonphone','$contactpersonemail','$contactpersonposition','$date','$coment')";
 48          $query2=mysqli_query($dbc,$sql2);
 49          echo '<br>Company Created Successfully.';
 50          header( "refresh:2;url=index.php" );
 51          echo '<br>You\'ll be redirected in about 5 secs. If not, click  <a href="index.php">here</a>.';
 52      
 53      }else{
 54      
 55      echo'Something went wrong!!!';
 56      }
 57    }
 58  
 59          
 60  ?>
Posted
Updated 23-Dec-21 8:34am
v3
Comments
0x01AA 23-Dec-21 13:25pm
   
What did you try?
Checking that code e.g. here ...

PHP Code Checker - Online syntax check[^]

... shows me where you are wrong ;)
Parse error: Unclosed '{' on line 36 in file on line 61
Errors parsing file

So do your homework first please

[Edit]
And yes, cool this K&R, Ratliff style. Unreadable for code blocks longer than 5 lines.... only my mind

[Edit1]
Removing line 2 at least helps to get rid of syntax errors ;) which makes also no sense
Member 13084733 23-Dec-21 13:54pm
   
Thank you for the link php checker it is working now please place it as solution so I can accept
0x01AA 23-Dec-21 13:56pm
   
Done, thanks.

Tools like
PHP Code Checker - Online syntax check[^]
helps to find the basic errors.
For the code you posted it shows me a first error
Parse error: Unclosed '{' on line 36 in file on line 61
Errors parsing file

I hope it helps.
Have a nice day, thanks.
   
Quote:
Parse error: syntax error, unexpected end of file

This means that every times you open a '{', you have to close it later.
See your code with correct indentation
PHP
<?php require_once("dataconfig.php"); ?>
<?php
if (isset($_POST['signup'])){

	$name=$_POST['company_name'];
	$cid=$_POST['company_id'];
	$adress=$_POST['adress'];
	$city=$_POST['City'];
	$state=$_POST['state'];
	$email=$_POST['email'];
	$phone=$_POST['Phone'];
	$owner=$_POST['owner'];
	$ownerphone=$_POST['ownerphone'];
	$contactperson=$_POST['contactperson'];
	$contactpersonphone=$_POST['contactpersonphone'];
	$contactpersonemail=$_POST['contactpersonemail'];
	$contactpersonposition=$_POST['contactpersonposition'];
	$coment=$_POST['coment'];
	$date=date('Y-m-d');
	if(filter_var($email, FILTER_VALIDATE_EMAIL)){
		$sql = mysqli_query($conn, "SELECT * FROM users WHERE email = '{$email}'");
		if(mysqli_num_rows($sql) > 0){
			echo "$email - This email already exist!";
		}else{
			if(isset($_FILES['image'])){
				$img_name = $_FILES['image']['name'];
				$img_type = $_FILES['image']['type'];
				$tmp_name = $_FILES['image']['tmp_name'];

				$img_explode = explode('.',$img_name);
				$img_ext = end($img_explode);

				$extensions = ["jpeg", "png", "jpg"];
				if(in_array($img_ext, $extensions) === true){
					$types = ["image/jpeg", "image/jpg", "image/png"];
					if(in_array($img_type, $types) === true){
						$time = time();
						$new_img_name = $time.$img_name;
						if(move_uploaded_file($tmp_name,"images/".$new_img_name)){
							$sql = "INSERT INTO `company`(`name`, `company_id`, `address`, `city`,`state`, `email`, `pnumber`, `Owner`, `Opnumber`) Values
							('$name','$cid','$adress','$city','$email','$phone','$owner','$ownerphone')" ;
							$query= mysqli_query($dbc,$sql);

							if ($query){

								$sql2 = "INSERT INTO `companyid`(`id`, `company_id`, `contact_person`, `name`, `email`, `adress`, `city`, `State`, `pNumber`, `Owner`, `contact_number`, `contact_email`, `Contact_position`, `date`, `Coment`) Values
								('','$cid','$contactperson','$name','$email','$adress','$city','$state','$phone','$owner','$contactpersonphone','$contactpersonemail','$contactpersonposition','$date','$coment')";
								$query2=mysqli_query($dbc,$sql2);
								echo '<br>Company Created Successfully.';
								header( "refresh:2;url=index.php" );
								echo '<br>You\'ll be redirected in about 5 secs. If not, click  <a href="index.php">here</a>.';

							}else{

								echo'Something went wrong!!!';
							}
						}


						?>

You have 6 missing '}'
   
Comments
0x01AA 23-Dec-21 15:12pm
   
You have 6 missing '}'
Nope ;)
Patrice T 23-Dec-21 17:22pm
   
At this point, 1 more or 1 less does not lake a real difference :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900