Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-26
7
Medium Priority
?
307 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 2000 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
What we learned in Webroot's webinar on multi-vector protection.
Six Sigma Control Plans
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

927 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