Click here to Skip to main content
16,020,673 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm getting this error associated with the line 306 "}".
the squiggly bracket is the only character on that line. here is the code:
PHP
  1  $postError = errorPOSTEmpty('wal_addr , title,fname ,lname,marital_stat,email,phone,dob_mon,dob_day,dob_year,addr1,addr2,city,state,zipcode,
  2  country,job_title ,employer,yrs_at_job,mon_income,rent_mort,ques_money_for_exp,ques_retire,ques_debt_paid_off,ques_cover_exp,ques_talk_fin_adv,
  3  ques_big_buy,ques_15_retire,ques_paid_off_home,form_fact');
  4  
  5  // define variables and set to empty values
  6  $wal_addrErr = $titleErr = $fnameErr = $lnameErr =
  7  $marital_statErr = $emailErr = $phoneErr = $dob_monErr =
  8  $dob_dayErr = $dob_yearErr = $addr1Err = $addr2Err =
  9  $cityErr = $stateErr = $zipcodeErr = $countryErr = $job_titleErr = 
 10  $employerErr = $yrs_at_jobErr = $mon_incomeErr = $rent_mortErr =
 11  $ques_money_for_expErr = $ques_retireErr = $ques_debt_paid_offErr =
 12  $ques_cover_expErr = $ques_talk_fin_advErr = $ques_big_buyErr = 
 13  $ques_15_retireErr = $ques_paid_off_homeErr = $form_factErr = "";
 14  
 15  $wal_addr = $title = $fname = $lname =
 16  $marital_stat = $email = $phone = $dob_mon =
 17  $dob_day = $dob_year = $addr1 = $addr2 =
 18  $city = $state = $zipcode = $country = $job_title = 
 19  $employer = $yrs_at_job = $mon_income = $rent_mort =
 20  $ques_money_for_exp = $ques_retire = $ques_debt_paid_off =
 21  $ques_cover_exp = $ques_talk_fin_adv = $ques_big_buy = 
 22  $ques_15_retire = $ques_paid_off_home = $form_fact = "";
 23  
 24  if (isset($_SERVER["REQUEST_METHOD"] == "POST")) {
 25       if (empty($_POST["wal_addr"])) {
 26        $wal_addrErr = "Wallet Address is required";
 27       } else {
 28      $wal_addr = test_input($_POST["wal_addr"]);
 29      // check if name only contains letters and whitespace
 30           if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$wal_addr)) {
 31           $wal_addrErr = "Only Numbers,letters and white space allowed";
 32             }
 33      }
 34  
 35    if (empty($_POST["title"])) {
 36      $titleErr = "Title is required";
 37    } else {
 38      $title = test_input($_POST["title"]);
 39      // check if name only contains letters and whitespace
 40      if (!preg_match("/^[a-zA-Z-'. ]*$/",$title)) {
 41        $titleErr = "Only letters and white space allowed";
 42      }
 43    }
 44  
 45    if (empty($_POST["fname"])) {
 46      $fnameErr = "First Name is required";
 47    } else {
 48      $fname = test_input($_POST["fname"]);
 49      // check if name only contains letters and whitespace
 50      if (!preg_match("/^[a-zA-Z-' ]*$/",$fname)) {
 51        $fnameErr = "Only letters and white space allowed";
 52      }
 53    }
 54  
 55  
 56    if (empty($_POST["lname"])) {
 57      $lnameErr = "Last Name is required";
 58    } else {
 59      $lname = test_input($_POST["lname"]);
 60      // check if name only contains letters and whitespace
 61      if (!preg_match("/^[a-zA-Z-' ]*$/",$lname)) {
 62        $lnameErr = "Only letters and white space allowed";
 63      }
 64    }
 65  
 66    if (empty($_POST["marital_stat"])) {
 67      $marital_stat = "Marital Status is required";
 68    } else {
 69      $marital_stat = test_input($_POST["marital_stat"]);
 70      // check if name only contains letters and whitespace
 71      if (!preg_match("/^[a-zA-Z-' ]*$/",$marital_stat)) {
 72        $marital_statErr = "Only letters and white space allowed";
 73      }
 74    }
 75    
 76    if (empty($_POST["email"])) {
 77      $emailErr = "Email is required";
 78    } else {
 79      $email = test_input($_POST["email"]);
 80      // check if e-mail address is well-formed
 81      if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
 82        $emailErr = "Invalid email format";
 83      }
 84    }
 85    
 86    if (empty($_POST["phone"])) {
 87      $phoneErr = "Phone is required";
 88      } else {
 89      $phone = test_input($_POST["phone"]);
 90      // check if name only contains letters and whitespace
 91      if (!preg_match("/^[0-9-' ]*$/",$phone)) {
 92        $phoneErr = "Only Numbers and white space allowed";
 93           }
 94        }  
 95    
 96     
 97    if (empty($_POST["dob_mon"])) {
 98      $dob_monErr = "Month is required";
 99    } else {
100      $dob_mon = test_input($_POST["dob_mon"]);
101      // check if name only contains letters and whitespace
102      if (!preg_match("/^[0-9-' ]*$/",$dob_mon)) {
103        $dob_monErr = "Only Numbers and white space allowed";
104      }
105    }  
106     
107    if (empty($_POST["dob_day"])) {
108      $dob_dayErr = "DAY is required";
109    } else {
110      $dob_day = test_input($_POST["dob_day"]);
111      // check if name only contains letters and whitespace
112      if (!preg_match("/^[0-9-' ]*$/",$dob_day)) {
113        $dob_dayErr = "Only Numbers and white space allowed";
114      }
115    } 
116     
117    if (empty($_POST["dob_year"])) {
118      $dob_yearErr = "YEAR is required";
119    } else {
120      $dob_year = test_input($_POST["dob_year"]);
121      // check if name only contains letters and whitespace
122      if (!preg_match("/^[0-9-' ]*$/",$dob_year)) {
123        $dob_yearErr = "Only Numbers and white space allowed";
124      }
125    }   
126   if (empty($_POST["addr1"])) {
127      $addr1Err = "Address 1 is required";
128    } else {
129      $addr1 = test_input($_POST["addr1"]);
130      // check if name only contains letters and whitespace
131      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$addr1)) {
132        $addr1Err = "Only Numbers,letters and white space allowed";
133      }
134    } 
135    
136    if (empty($_POST["city"])) {
137      $city = "CITY is required";
138    } else {
139      $city = test_input($_POST["city"]);
140      // check if name only contains letters and whitespace
141      if (!preg_match("/^[a-zA-Z-' ]*$/",$city)) {
142        $cityErr = "Only letters and white space allowed";
143      }
144    }
145   
146    if (empty($_POST["state"])) {
147      $state = "STATE is required";
148    } else {
149      $state = test_input($_POST["state"]);
150      // check if name only contains letters and whitespace
151      if (!preg_match("/^[a-zA-Z-' ]*$/",$state)) {
152        $stateErr = "Only letters and white space allowed";
153      }
154    }
155    
156    if (empty($_POST["zipcode"])) {
157      $zipcodeErr = "ZIPCODE is required";
158    } else {
159      $zipcode = test_input($_POST["zipcode"]);
160      // check if name only contains letters and whitespace
161      if (!preg_match("/^[0-9-' ]*$/",$zipcode)) {
162        $zipcodeErr = "Only Numbers and white space allowed";
163      }
164    } 
165     
166    if (empty($_POST["country"])) {
167      $country = "COUNTRY is required";
168    } else {
169      $country = test_input($_POST["country"]);
170      // check if name only contains letters and whitespace
171      if (!preg_match("/^[a-zA-Z-' ]*$/",$country)) {
172        $countryErr = "Only letters and white space allowed";
173      }
174    }
175   
176    if (empty($_POST["job_title"])) {
177      $job_title = "OCCUPATION is required";
178    } else {
179      $job_title = test_input($_POST["job_title"]);
180      // check if name only contains letters and whitespace
181      if (!preg_match("/^[a-zA-Z-' ]*$/",$job_title)) {
182        $job_titleErr = "Only letters and white space allowed";
183      }
184    }
185   
186    if (empty($_POST["employer"])) {
187      $employer = "EMPLOYER is required";
188    } else {
189      $employer = test_input($_POST["employer"]);
190      // check if name only contains letters and whitespace
191      if (!preg_match("/^[a-zA-Z-' ]*$/",$empoyer)) {
192        $employerErr = "Only letters and white space allowed";
193      }
194    }
195  if (empty($_POST["yrs_at_job"])) {
196      $yrs_at_jobErr = "Years at your Job is required";
197    } else {
198      $yrs_at_job = test_input($_POST["yrs_at_job"]);
199      // check if name only contains letters and whitespace
200      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$yrs_at_job)) {
201        $yrs_at_jobErr = "Only Numbers,letters and white space allowed";
202      }
203    } 
204  if (empty($_POST["mon_income"])) {
205      $mon_incomeErr = "Monthly Income is required";
206    } else {
207      $mon_income = test_input($_POST["mon_income"]);
208      // check if name only contains letters and whitespace
209      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$mon_income)) {
210        $mon_incomeErr = "Only Numbers,letters and white space allowed";
211      }
212    } 
213  if (empty($_POST["rent_mort"])) {
214      $rent_mortErr = "Rent/Mortgage is required";
215    } else {
216      $rent_mort = test_input($_POST["rent_mort"]);
217      // check if name only contains letters and whitespace
218      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$rent_mort)) {
219        $rent_mortErr = "Only Numbers,letters and white space allowed";
220      }
221    } 
222  if (empty($_POST["ques_money_for_exp"])) {
223      $ques_money_for_expErr = "Money for Expenses is required";
224    } else {
225      $ques_money_for_exp = test_input($_POST["ques_money_for_exp"]);
226      // check if name only contains letters and whitespace
227      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_money_for_exp)) {
228        $ques_money_for_expErr = "Only Numbers,letters and white space allowed";
229      }
230    } 
231  if (empty($_POST["ques_retire"])) {
232      $ques_retireErr = "Retirement Answer is required";
233    } else {
234      $ques_retire = test_input($_POST["ques_retire"]);
235      // check if name only contains letters and whitespace
236      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_retire)) {
237        $ques_retireErr = "Only Numbers,letters and white space allowed";
238      }
239    } 
240  if (empty($_POST["ques_debt_paid_off"])) {
241      $ques_debt_paid_offErr = "Debt Answer is required";
242    } else {
243      $ques_debt_paid_off = test_input($_POST["ques_debt_paid_off"]);
244      // check if name only contains letters and whitespace
245      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_debt_paid_off)) {
246        $ques_debt_paid_offErr = "Only Numbers,letters and white space allowed";
247      }
248    } 
249  if (empty($_POST["$ques_cover_exp"])) {
250      $ques_cover_expErr = "Expense Answer is required";
251    } else {
252      $ques_cover_exp = test_input($_POST["$ques_cover_exp"]);
253      // check if name only contains letters and whitespace
254      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_cover_exp)) {
255        $ques_cover_expErr = "Only Numbers,letters and white space allowed";
256      }
257    } 
258  if (empty($_POST["ques_talk_fin_adv"])) {
259      $ques_talk_fin_advErr = "Financial Advisor Answer is required";
260    } else {
261      $ques_talk_fin_adv = test_input($_POST["ques_talk_fin_adv"]);
262      // check if name only contains letters and whitespace
263      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_talk_fin_adv)) {
264        $ques_talk_fin_advErr = "Only Numbers,letters and white space allowed";
265      }
266    } 
267  if (empty($_POST["ques_big_buy"])) {
268      $ques_big_buyErr = "Big Purchase Answer is required";
269    } else {
270      $ques_big_buy = test_input($_POST["ques_big_buy"]);
271      // check if name only contains letters and whitespace
272      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_big_buy)) {
273        $ques_big_buyErr = "Only Numbers,letters and white space allowed";
274      }
275    } 
276  if (empty($_POST["ques_15_retire"])) {
277      $ques_15_retireErr = "15 Percent Answer is required";
278    } else {
279      $ques_15_retire = test_input($_POST["ques_15_retire"]);
280      // check if name only contains letters and whitespace
281      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_15_retire)) {
282        $ques_15_retireErr = "Only Numbers,letters and white space allowed";
283      }
284    } 
285  if (empty($_POST["ques_paid_off_home"])) {
286      $ques_paid_off_homeErr = "Home Paid Answer is required";
287    } else {
288      $ques_paid_off_home = test_input($_POST["ques_paid_off_home"]);
289      // check if name only contains letters and whitespace
290      if (!preg_match("/^[a-zA-Z0-9-' ]*$/",$ques_paid_off_home)) {
291        $ques_paid_off_homeErr = "Only Numbers,letters and white space allowed";
292      }
293    } 
294  
295    if (empty($_POST["form_fact"])) {
296      $form_fact = "Selection is required";
297    } else {
298      $form_fact = test_input($_POST["job_title"]);
299      // check if name only contains letters and whitespace
300      if (!preg_match("/^[a-zA-Z-' ]*$/",$form_fact)) {
301        $form_factErr = "Only letters and white space allowed";
302      }
303  }
304  if (isset($postError === false)) {
305  header("location:https://solvenet.000webhostapp.com/loan_db.php?wal_addr='.$_POST['wal_addr'].'&title='.$_POST['title'].'
306  &fname='.$_POST['fname'].'&lname='.$_POST['lname'].'&marital_stat='.$_POST['marital_stat'].'&email='.$_POST['email'].'
307  &phone='.$_POST['phone'].'&dob_mon='.$_POST['dob_mon'].'&dob_day='.$_POST['dob_day'].'&dob_yr='.$_POST['dob_yr'].'
308  &addr1='.$_POST['addr1'].'&addr2='.$_POST['addr2'].'&city='.$_POST['city'].'&state='.$_POST['state'].'&zipcode='.$_POST['zipcode'].'
309  &country='.$_POST['country'].'&job_title='.$_POST['job_title'].'&employer='.$_POST['employer'].'&yrs_at_job='.$_POST['yrs_at_job'].'
310  &mon_income='.$_POST['mon_income'].'&rent_mort='.$_POST['rent_mort'].'&ques_money_for_exp='.$_POST['ques_money_for_exp'].'
311  &ques_retire='.$_POST['ques_retire'].'&ques_debt_paid_off='.$_POST['ques_debt_paid_off'].'&ques_cover_exp='.$_POST['ques_cover_exp'].'
312  &ques_talk_fin_adv='.$_POST['ques_talk_fin_adv'].'&ques_big_buy='.$_POST['ques_big_buy'].'&ques_15_retire='.$_POST['ques_15_retire'].'
313  &ques_paid_off_home='.$_POST['ques_paid_off_home'].'&form_fact='.$_POST['form_fact'].'"); 
314  }
315  
316  function test_input($data) {
317    $data = trim($data);
318    $data = stripslashes($data);
319    $data = htmlspecialchars($data);
320    return $data;
321  }
322  
323  }


Please advise me on how to fix this error. Thanks in advance.

Starkephp

What I have tried:

still evaluating options for a solution.
Posted
Updated 30-Oct-22 11:24am
v3

We have no idea which line is "line 306": if I past that into a text editor, line 306 is this:
PHP
&fname='.$_POST['fname'].'&lname='.$_POST['lname'].'&marital_stat='.$_POST['marital_stat'].'&email='.$_POST['email'].'

And since we have no idea how to run your code, or what it is supposed to do we can't even begin to work out where it goes wrong in a reasonable timeframe, given that PHP is interpreted so syntax errors only show up when they are met during execution.

You should expect to get syntax errors every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a keyword; sometimes we forget to close a string or a code block. Sometimes the cat walks over your keyboard and types something really weird. Sometimes we just forget how many parameters a method call needs.

We all make mistakes.

And because we all do it, we all have to fix syntax errors - and it's a lot quicker to learn how and fix them yourself than to wait for someone else to fix them for you! So invest a little time in learning how to read error messages, and how to interpret your code as written in the light of what the compiler is telling you is wrong - it really is trying to be helpful!

So read this: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] - it should help you at least isolate where the error is and the actual code that causes it!
 
Share this answer
 
Solved it. Just switch the double quote to a single quote in the header('location'). thanks
 
Share this answer
 

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