Solved

causing an error in my syntax for my validating my form for my database

Posted on 2011-02-26
7
295 Views
Last Modified: 2013-11-13
I am still having  problems with sending my info to my database its not validating and  this is the error that is telling me
Parse error: syntax error, unexpected T_BOOLEAN_AND
 validate1.html
 validate1a.php
0
Comment
Question by:imagekrazy
  • 5
  • 2
7 Comments
 
LVL 14

Accepted Solution

by:
Scott Madeira earned 500 total points
ID: 34988715
You have a syntax error onlines 18 and 19 (your two if statements...   Too many parenthesis and not teh same number of opens and closes.  Try these:

if ( !empty($frstname) && !empty($lstname) )     {
      
            if (!empty($email) || !empty($about_yourself)) {
0
 

Author Comment

by:imagekrazy
ID: 34989408
Hi, I did that , and it spit out an error--

Parse error: syntax error, unexpected '{' in


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>front page form</title>
</head>

<body>
<h2>  Please fill out the form or it wont be sent!</h2>

<?php
   
    $frstname= $_POST['frstname'];
    $lstname= $_POST['lstname'];
    $email= $_POST['email'];
    $about_yourself= $_POST['about_yourself'];
      
if(!empty($frstname)&&(!empty($lstname))     {
      
            if(!empty($email) || (!empty($about_yourself)) {
                  
            

$dbc = mysqli_connect('myvebsite.db.2150637.hostedresource.com','myvebsite','Jeep123','myvebsite')
or die('Error connecting to MySQL server.');

$query= "INSERT INTO emaills_hhl (frstname,lstname,email,about_yourself)".
         "VALUES ('$frstname','$lstname','$email','$about_yourself')";
             
$data = mysqli_query($dbc,$query)
or die('MySQL error:' . mysqli_error($dbc) . "<hr>\nQuery: $query");

//$result = mysqli_query($dbc,$query)
       // or die('Error query database.');
            //or die('Error:' .mysqli_error($dbc));
            
 while ($row = mysqli_fetch_array($result)){
      $to =$row['email'];
      $frstname = $row['frstname'];
      $lstname = $row['lstname'];
      $about_yourself = $row['about_yourself'];
      $msg = "Dear $frstname $lstname $about_yourself ,\n$text";
      mail($to,$subject,$msg,'From:' . $from);
      echo 'Email senbt to '.$to. '<br>';
  }
            

mysqli_close($dbc);
                  }
            }
      
 

//      echo 'Thanks for submitting the form.<br/>';
//      echo 'Your first name ' . $frstname.'<br/>';
//      echo 'Your last name ' . $lstname.'<br/>';
//      echo 'Your email ' . $email.'<br/>';
//      echo 'Your message '.$about_yourself;
      
      
      
      ?>
      
      
</body>
</html>
0
 

Author Comment

by:imagekrazy
ID: 34989427
oops i missed two {{ then i did it again and it is saying this;

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Expert Comment

by:Scott Madeira
ID: 34990105
You changed variable names.  you have:

$data = mysqli_query($dbc,$query)
or die('MySQL error:' . mysqli_error($dbc) . "<hr>\nQuery: $query");


which executes the query.  Then you have these commented lines

//$result = mysqli_query($dbc,$query)
       // or die('Error query database.');
            //or die('Error:' .mysqli_error($dbc));
           
Here you are trying to use $result as your result set but you used $data for the query result above.

 while ($row = mysqli_fetch_array( $result  )){
      $to =$row['email'];
      $frstname = $row['frstname'];
      $lstname = $row['lstname'];
      $about_yourself = $row['about_yourself'];
      $msg = "Dear $frstname $lstname $about_yourself ,\n$text";
      mail($to,$subject,$msg,'From:' . $from);
      echo 'Email senbt to '.$to. '<br>';
0
 

Author Comment

by:imagekrazy
ID: 34991515
Its still giving me  the error

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean

my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>front page form</title>
</head>

<body>
<h2>  Please fill out the form or it wont be sent!</h2>

<?php
   
    $frstname= $_POST['frstname'];
    $lstname= $_POST['lstname'];
    $email= $_POST['email'];
    $about_yourself= $_POST['about_yourself'];
      
if(!empty($frstname)&&!empty($lstname))     {
      
            if(!empty($email) ||!empty($about_yourself)) {
                  
            

$dbc = mysqli_connect('myvebsite.db.2150637.hostedresource.com','myvebsite','Jeep123','myvebsite')
or die('Error connecting to MySQL server.');

$query = "INSERT INTO emaills_hhl (frstname,lstname,email,about_yourself)".
         "VALUES ('$frstname','$lstname','$email','$about_yourself')";
             
$query = mysqli_query($dbc,$query)
or die("MySQL error:" . mysqli_error($dbc) . "<hr>\nquery: $query");


            
 while ($row = mysqli_fetch_array($query)){
      $to =$row['email'];
      $frstname = $row['frstname'];
      $lstname = $row['lstname'];
      $about_yourself = $row['about_yourself'];
      $msg = "Dear $frstname $lstname $about_yourself ,\n$text";
      mail($to,$subject,$msg,'From:' . $from);
      echo 'Email senbt to '.$to. '<br>';
  }
            

mysqli_close($dbc);
                  }
            }
      
 


      
      
      
      ?>
      
      
</body>
</html>
0
 

Author Comment

by:imagekrazy
ID: 34991847
i hit the wrong button
0
 

Author Closing Comment

by:imagekrazy
ID: 34991851
thanks, I am going to re post it after i fix a few things
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
This article discusses four methods for overlaying images in a container on a web page
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now