Solved

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

Posted on 2011-02-26
7
296 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 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

23 Experts available now in Live!

Get 1:1 Help Now