Solved

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

Posted on 2011-02-26
7
297 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
form builder not starting 3 34
ASP/VB email question 4 34
Query Syntax 17 34
ORA-02288: invalid OPEN mode 2 27
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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