Solved

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

Posted on 2011-02-26
7
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

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.
Part One of the two-part Q&A series with MalwareTech.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

628 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