Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6960897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:27:38+00:00 2026-05-27T15:27:38+00:00

I am trying to get my php validate that the user has put in

  • 0

I am trying to get my php validate that the user has put in the info that is needed.

I want to make sure that the person has put in there name and email. When I put just:

if(empty($name){
  blah blah
}

it gives the error but it still process the email. When I put:

if(empty($name){
  blah blah
}else{
  blah blah
}

I get an error saying: Parse error: syntax error, unexpected '}' in /home/dreamcpu/public_html/insert.php on line 34.

Here is my php:

<?php
$con = mysql_connect("localhost","blah","blah");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$today = date("F j, Y, g:i a"); 
mysql_select_db("dreamcpu_contact_info", $con);
$sql="INSERT INTO contact_us (name, email,phone_number,job_request,DateRequested)
VALUES
('$_POST[name]','$_POST[email]','$_POST[phone_number]','$_POST[job_requested]','$today')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error(). "Actual query: " . $sql);
}
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone_number'];
$job = $_POST['job_requested'];
if (empty($name)){
echo "The name field was blank. Please go back and fill in the required fields";
}
else
{
$to = "programmers@dreamcpu.com";
$subject = "A job have been requested";
$message = "On " . $today . " a job has been requested from " . $name . " please email them at " . $email . " or call them at " . $phone;
$headers = "From:" . $email;
mail($to, $subject, $message,$headers);
echo "<h3 style='display:block;'>Thank you for contacting DreamCPU. We have received   your request $_POST[name]. We will review it and contact you as soon as possible.</h3>";
mysql_close($con);
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:27:39+00:00Added an answer on May 27, 2026 at 3:27 pm

    You forgot a semicolon:

    mysql_close($con);
    -----------------^
    

    The variable inside your string should also not be relying on constants:

    echo " ... request $_POST['name']. We will ...";
    --------------------------^----^
    

    You also forgot a closing bracket on this line:

    if(empty($name)){
    ---------------^
      blah blah
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to validate my output data from a php site that Im calling
When im trying to validate my page on http://validator.w3.org/ i get one error that
I'm trying to get php to automatically pass the session ID via url, even
I'm trying to get a PHP site working in IIS on Windows Server with
I'm trying to get the php executable to parse scripts, but it's not working.
I have been having some problems trying to get my PHP running. When I
I am trying to get some accurate runtime comparisons of PHP vs Python (and
I am new to PHP and trying to get the following code to work:
I was trying to get my Netbeans to autocomplete with PHP , and I
I am trying to get my Mac setup as a php server, however, as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.